How do I prevent flipping back objects angle in 8direction

Get help using Construct 2

Post » Sun Sep 14, 2014 7:37 pm

Hello,

in my game I use 8direction with keyboard controls for player movement. After release of the diagonals (left/up, left/down and so on), the player object always flips back to one of the 4direction angles (0°, 90°, 180°, 270°).

How can i prevent this flipping?

Thanks
B
4
Posts: 4
Reputation: 208

Post » Sun Sep 14, 2014 7:57 pm

Would adding an on any key released sprite set angle : sprite.8Direction.MovingAngle work?
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 » Sun Sep 14, 2014 9:10 pm

Sadly this doesn`t work. Im using an adapted 8dir from the tutorial "Animation Management in 8-Direction Games" by stemkoski.
I attached a Capx.

Any idea how to implement my needs?
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 4
Reputation: 208

Post » Tue Sep 16, 2014 8:37 am

1. add instance variable "movingAngle" on your Player
2. (Add event)
---keyboard -> On any key released
---player -> is moving

(Add action)
---Player -> Set value -> movingAngle= Player.angle

3. (Add event)
---Player -> is moving -> invert

(Add action)
---Player -> Set angle -> Player.movingAngle degrees
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
63
S
14
G
2
Posts: 291
Reputation: 6,641

Post » Tue Sep 16, 2014 8:36 pm

Thank you very much puntodamar.

After diagonal move player object and so the player animation are flipping to the correct angle. Is there a way to let it look more clean?

My idea was to make this flipping so fast that it would not be visual for the eye. I added an every tick event. Didn´t work.
I reduced the angles in the player movement events. Also no great idea.

Im stuck and need help.

Thanks
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 4
Reputation: 208

Post » Wed Sep 17, 2014 5:03 pm

inside "Player Movement" group, delete all events with "Is between angles" condition.
then, add the following events inside "Player Controls" group

1. Keyboard -> Key A & W is down
--- Player -> set angle to 255, set DirectionName to "NW", set movingAngle to Player.Angle

2. Keyboard -> A & S is down
--- Player -> set angle to 135, set DirectionName to "SW", set movingAngle to Player.Angle

3. Keyboard -> Key D & S is down
--- Player -> set angle to 45, set DirectionName to "SE", set movingAngle to Player.Angle

4. Keyboard -> Key D & W is down
--- Player -> set angle to 255, set DirectionName to "NE", set movingAngle to Player.Angle


5. delete event 15

it's not completely fixed, because you have to release two button together to make it happen.
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
63
S
14
G
2
Posts: 291
Reputation: 6,641


Return to How do I....?

Who is online

Users browsing this forum: luckyrawatlucky, nahima and 7 guests