Easy character selection

4

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

8,227 visits, 11,688 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 9 Dec, 2016. Last updated 19 Feb, 2019

Have you ever wanted to make a game with lots of characters? For exemple, fighting games have a menu in which you can choose what character you want to play with and sometimes even what enemy you want to fight against. So, how do you do that?

Most people will think that they need to make a separate layout for every possible character vs enemy combination, like for exemple:

layout 1 is character1 vs enemy 1

layout 2 character 2 vs enemy 1

layout 3 character 3 vs enemy 1

and then again, character 1, 2, 3 against enemy 2 and character 1,2,3 against enemy 3 etc.

If you only have 2-3 charcaters, its ok, but what if you want to have 10-20? Are you going to do a layout for every possible combination? No way.

The easy way is to use global variables. Create 2 global variables, one for characters and one for enemies.

Now, for this exemple, I will use 3 character and 3 enemies but the method works no matter how many characters/enemies you have.

When player chooses character 1, the global variable is equal to 0. If he/she chooses character 2, the variable changes to 2, etc. and the same with the other variable with the enemies.

Now, after the player chose the character and the enemy, and clicks on play, he/she expects the selected character and enemy to appear on the game layout. We can easily do that by spawning the character and the enemy based on the variable value.

If the selectCH variable is 0, character 1 will appear. If selectCH=1, character 2 will appear, etc and the same will happen with the enemy.

This way, no matter how many characters/enemies you have, you can spawn them on your game layout. Now you dont have to make a layout for every possible character-enemy combination that the player may choose. Hope it helped! :)

.CAPX
  • 5 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Hi

    This is very helpful but I've hit a newbie issue. As we are creating the players as objects from the event sheet; how can I add instance variables and platform settings as it doesn't appear in the layout tab? Thanks in advance.

  • hello animelover07

    i followed this step and understand everything. i would like to explore more on this. i am making a game where user uploads his photo which automatically applies to the game character. i am stuck at this step

    • Oh, this sounds a bit more challenging! I have never tried it before. I'm not sure how I would do that but probably the method would also use variables. Maybe you can search on youtube? Perhaps you'll find someone who has tried doing this.

  • Is there one for Construct 3?