How do I toggle between two different animations with...

Get help using Construct 2

Post » Tue Aug 04, 2015 4:12 pm

... the same button?

I'm making a game where you are required to hide behind your hands to hide from monsters. I want to use space to hide and "not hide", so how would I toggle between the two animations with space?
B
5
S
1
Posts: 73
Reputation: 521

Post » Tue Aug 04, 2015 4:22 pm

in psuedo code it would be something like this:

on space pressed
-- if hide is true
> unhide
-- else
> hide
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Aug 04, 2015 4:23 pm

create some sort of flag.

make an instance variable on the object.. something like "isHiding" init it to false.

If isHiding.....set animation to ABC, set isHiding=false

else If XisHiding.....set animation to XYZ, set isHiding=true

*this last part is inverted so it reads: if NOT true
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Tue Aug 04, 2015 4:26 pm

@LittleStain is right.. if there are only 2 animations you only need to do an else and don't need and 'else if' since it's an either or situation..
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Tue Aug 04, 2015 7:32 pm

LittleStain wrote:in psuedo code it would be something like this:

on space pressed
-- if hide is true
> unhide
-- else
> hide


@LittleStain

What would that be physically in Construct then? I'm not very experienced :P
B
5
S
1
Posts: 73
Reputation: 521


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests