Flip sprite based on 8-direction direction

Get help using Construct 2

Post » Thu Jan 24, 2013 3:13 am

I have a sprite that should either be pointing left or right. The sprite has an 8-direction behavior, but the sprite shouldn't point any direction... only left or right. I would expect to create a new event based on the 8-direction's angle, but I don't see that as an option.codefoster2013-01-24 03:20:15
B
15
S
5
Posts: 28
Reputation: 1,533

Post » Thu Jan 24, 2013 4:48 am

Does your sprite have 2 frames in the animation? One facing left and one facing right?

On key pressing left, use frame 1
On key pressing right, use frame 0

Something like that? Or did I misunderstand your question?
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Thu Jan 24, 2013 4:52 am

If I understood you correctly ...

Create two animations, Left and Right, with the sprite pointing the appropriate way in each animation.

In your sprite's 8Direction behavior, set "Set angle" to be "No".

Add a keyboard object, and do:

Keyboard -> On Left Arrow Pressed, set animation to "Left"
Keyboard -> On Right Arrow Pressed, set animation to "Right"

Matt
B
6
S
2
G
3
Posts: 10
Reputation: 2,402

Post » Thu Jan 24, 2013 6:22 am

Well, instead of using animation frame 1 or 2 I think I can just set mirrored and UNset mirrored, but I see you're both saying that I need to trigger off of the user input. I was hoping to get the event from the actual sprite's direction though because I plan to implement touch and mouse and then I'll just be repeating those event conditions or create big or... or... or... statements. But that will do it. Thanks.
B
15
S
5
Posts: 28
Reputation: 1,533

Post » Thu Jan 24, 2013 1:46 pm

B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Fri Jan 25, 2013 12:33 am

I like that answer @ramones. That way it doesn't matter how you change the sprites direction (keyboard, mouse, touch, accelerometer, etc).
B
11
S
2
G
3
Posts: 10
Reputation: 3,026

Post » Sat Feb 02, 2013 4:33 am

That worked a beaut! Thanks, @ramones.
B
15
S
5
Posts: 28
Reputation: 1,533


Return to How do I....?

Who is online

Users browsing this forum: Callan S, getplay and 28 guests