How do I go about choosing characters with diferent movesets

Get help using Construct 2

Post » Fri Oct 31, 2014 3:22 pm

Hey guys, I'm trying to think of how I would go about doing this. Maybe store variables labeled for each move? All of the characters animations are named the same ex: Idle, Run, Jump etc. Has anyone done this before?
B
7
S
1
Posts: 28
Reputation: 459

Post » Fri Oct 31, 2014 4:00 pm

Look into Families. Create a Family called "Player", and then set the animation of "Player" to Idle, Run, Jump etc. You might need a "playerNumber" variable on the family so you can assign different controls to each player.
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Fri Oct 31, 2014 4:33 pm

How would I go about assigning different controls to each player? I just figured out the choosing character part thanks to you :)
B
7
S
1
Posts: 28
Reputation: 459

Post » Fri Oct 31, 2014 6:18 pm

Glad you were able to figure that out! :-)

I think a reasonable approach would be to have an instance variable for each action. Assuming a two-button game where you can move left and right, you might add the instance variables "leftButton" and "rightButton" to your "Player" family's instance variables. These variables will store the key codes for each action.

Continuing this example, you could set P1's leftButton to 37 (which is the left arrow key) and the rightButton to 39 (the right arrow key). You could set P2's leftButton to 65 (which is 'A') and the rightButton to 68 (which is 'D'). Once each player on screen has a different set of controls, the following event logic will work to control the players:

Code: Select all
For each "Player"
   Key Code Player.leftButton is down   | Move "Player" Left
   Key Code Player.rightButton is down  | Move "Player" right


Basically it's asking each player what their button for a particular action is, then checking to see if that button is pressed. if it is, then do what needs to be done to that Player to execute that action e.g setting animations, moving the player, etc. In this manner, you can assign all of your controls.

That's the basic approach. There could be a better one, but this might give you some ideas.
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 50 guests