Set animation frame based on mouse direction

Get help using Construct 2

Post » Tue Apr 02, 2013 12:47 am

Hello,

I have seen various examples of this, however I cant seem to get this to work.

What I am trying to do is:

1. If mouse is moving Up set animation frame to 0
2. if mouse is moving Down set animation frame to 1
3. if mouse is moving Left set animation frame to 2
4. if mouse is moving Right set animation frame to 3

A capx would help so much for me to visually understand how to do this in Construct 2. I am able to do this kind of thing in Actionscript 3 but not CS2 :(DrathVader2013-04-02 00:48:19
B
7
S
1
Posts: 48
Reputation: 1,729

Post » Tue Apr 02, 2013 11:03 pm

Every tick you would compare the previous location to the one before it.

global variable "PreviousX"
global variable "PreviousY"

system every tick
->set variable PreviousX to Mouse AbsoluteX
->set variable PreviousY to Mouse AbosluteY

compare system variable PreviousX < Mouse absolute X
-> Sprite Set Frame "3"
compare system variable PreviousX < Mouse absolute X
-> Sprite Set Frame "2"
compare system variable PreviousY < Mouse absolute Y
-> Sprite Set Frame "0"
compare system variable PreviousY > Mouse absolute Y
-> Sprite Set Frame "1"


B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Tue Apr 09, 2013 6:40 pm

PERFECT :) thank you very much for the help!!
B
7
S
1
Posts: 48
Reputation: 1,729


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests