How do I make attack aniamtions cancel running

Just started using Construct 2? Post your questions here

Post » Fri Nov 25, 2016 3:22 am

I'm just using a basic 'while left key is down/player is on ground - play animation runleft' thing going on, but it means that I have a 'on space bar pressed' and 'while left key is down' 'play animation attack left' but the running left animation is still taking priority and the attack animation will only play. How can I make it so that the attack animation will cancel the run animation and play the attack animation instead?
B
6
Posts: 7
Reputation: 264

Post » Sat Nov 26, 2016 2:01 pm

One option is to create "states" using variables.

ie. create variable called states=0 and then change it for example:

idle states: state=0
running state: state=1
jumping state: state=2
attacking state: state=3

You can then stop/start animations/events based on the conditioning of these variables.

Example: Space bar pressed, change state to 3. If state=3 run animation stops.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
70
S
19
G
8
Posts: 639
Reputation: 9,674

Post » Sun Nov 27, 2016 3:13 am

Thanks, I ended up solving the problem just by changing 'while left key is down' to 'when left key is pressed' though on the run animation. So that it didn't keep overwriting the attack animation.
B
6
Posts: 7
Reputation: 264

Post » Sun Nov 27, 2016 12:43 pm

That works too.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
70
S
19
G
8
Posts: 639
Reputation: 9,674

Post » Sun Nov 27, 2016 1:08 pm

Hello. I have a similar problem. When my character is running and I press "F" the attack animation simply freezes on the first frame until I let go of "F". I'm trying to do it with instance variables, but I fear I'm doing them wrong or there is a logic problem.
B
3
Posts: 1
Reputation: 177

Post » Sun Nov 27, 2016 4:46 pm

@DarijuSlav You need to provide capx files or sreenshots of your issue. Not enough information to tell what's going on there.
B
34
S
9
G
3
Posts: 206
Reputation: 7,851


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests