Diagonal walking issue

For questions about using Classic.

Post » Sat Jun 16, 2012 11:49 am

Hi all!

I have searched through google, read the FAQ and browsed various guides but I haven't found a solution.

I am sure it's something simple.

My little program is basically making a sprite move with the arrow keys. I'm not using a behaviour for this but just polling keys and changing the X and Y properties of the sprite.

Depending on what key is pressed I swap out animations so that the sprite is walking.

This works well but I can't get it to work when you press up and right for example. I want diagonal movements to be like left and right (so if I press up end right I want the right "walking right" animation to play.

My naming convention for the animation is simple like SL (Standing and looking left) or WU (Walking up).

Here is my cap file: https://www.dropbox.com/s/wpb53dlchye5vh4/Walking%20Animation.cap

B
5
Posts: 23
Reputation: 1,038

Post » Sat Jun 16, 2012 2:33 pm

You just answered your question. If you want to play the "walking right" when you press the up and right buttons, create the event where you set these rules. Something like this:

+ MouseKeyboard: Key Up arrow is down
+ MouseKeyboard: Key Right arrow is down
+ System: OR
+ MouseKeyboard: Key Right arrow is down
-> Character: Set animation to "WR"

You should handle the animations in different events than the movements, or this solution will not work correctly of course.

Note: if you would like to change the controls in the future you will have a lot of trouble, use some pv instead.

+ MouseKeyboard: Key Right arrow is down
-> Character: Set 'state' to "R"

+ Character: Value 'state' Equal to "R"
-> Character: Set X to Character.X +1
This way you only have to change the first event if you want to switch to wasd for example, not the whole sheet.
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sat Jun 16, 2012 4:06 pm

Thanks for the help!

I removed the movement for now and just trying to get the animations working.

When I remove the code for going straight up and down the animations work like I want them. But adding the code for going straight up and down breaks the diagonal animations again.

DropBox file has been updated and here is a screenshot of the code:

B
5
Posts: 23
Reputation: 1,038

Post » Sat Jun 16, 2012 4:16 pm

You are welcome. Put these inverted events in your sheet and it will work correctly.
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sat Jun 16, 2012 4:39 pm

Oh wow thank you for your help!

Looking at the code I'm actually shocked how many lines it took for this to work right. I actually didn't know about the "Invert Condition" feature, so that was very helpful.

I have again uploaded the final code: https://www.dropbox.com/s/wpb53dlchye5vh4/Walking%20Animation.cap

And here the code. Maybe someone else will run into this problem :)


Mau1wurf19772012-06-16 16:41:41
B
5
Posts: 23
Reputation: 1,038

Post » Sun Jan 27, 2013 3:02 pm

Hey guys,

I have the same problem yet no matter how much i looked for, i just couldnt find how to add an "OR" to the conditions. I can make an "OR block" but then it'll place -OR- between every single conditions.

Thanks for your help already.
B
3
Posts: 1
Reputation: 277


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests