How do I switch between two different characters?

Get help using Construct 2

Post » Thu May 04, 2017 7:47 am

I don't know how to switch between two different characters pressing a key (I mean, I want to be able to switch between them pressing the space bar while im playing) its possible to do it?

No se como cambiar entre dos personajes presionando una tecla (quiero decir, quiero poder cambiar entre ellos presionando la barra espaciadora mientras estoy jugando) es posible hacer eso?
B
6
S
2
G
1
Posts: 4
Reputation: 967

Post » Thu May 04, 2017 9:09 am

doodliver wrote:I don't know how to switch between two different characters pressing a key (I mean, I want to be able to switch between them pressing the space bar while im playing) its possible to do it?


You need to use instance variables, because there is no condition to see if the platform or 8direction behavior is enabled.
You have to set the instance-variables on the start in a state that make sense (one characters has to be the controls enabled the other not). Then you have only to change the instance variables and the conditions.
I made a little example.
https://drive.google.com/uc?export=down ... XdLTE1XZWM
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Fri May 05, 2017 1:35 am

thank you for reply, I tried to apply what you did in my own project but I got "Else (not valid here)" I don't know what to do about it
B
6
S
2
G
1
Posts: 4
Reputation: 967

Post » Fri May 05, 2017 6:26 am

Be sure that that the else follows direct after the previous event and not as a subevent. It doesn't work with triggered conditions (the one with the green arrow).

Run if the previous event did not run. Note that this condition does not pick any objects: if it follows an event that picks objects, in the Else event all instances revert to picked again. Else can only follow normal (non-triggered) events. It can also follow another Else event with other conditions to make an "if - else if - else" chain.

https://www.scirra.com/manual/124/system-conditions
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Fri May 05, 2017 10:48 pm

I will try it and see what happens, but I have a doubt, when I press a key (the X) If I'm using the sprite 1 while I'm playing, I dont want the sprite 2 to be in the game and viceversa, what you're teaching me works like that? or both sprites will be in the screen?
B
6
S
2
G
1
Posts: 4
Reputation: 967

Post » Sat May 06, 2017 9:02 am

doodliver wrote:I dont want the sprite 2 to be in the game and viceversa, what you're teaching me works like that? or both sprites will be in the screen?


There are both sprite at the same time on the screen in my example. There are several possibilities to have only one sprite at the time on the screen. You can put one sprite outside the layout, make it invisible or destroy it and create a new one every time you switch. I't depends what you want to achieve.
If it is regardless which position the sprites are after switching make them invisible. If you want to switch positions of the sprites set Sprite1 on position of sprite2 and then sprite2 outside of the layout and vice versa.
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Tue May 23, 2017 11:54 pm

i managed how to switch between them but pressing A for one of them and B for the other, i have a fox and a wolf, the fox is supposed to be faster than the wolf, now I have a problem, when I switch between them they dont appear in the same place where the other was at first, one of them almost always appears more far than the other (because the fox is faster), Im sorry for the late reply, Im very sick
B
6
S
2
G
1
Posts: 4
Reputation: 967


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 43 guests