Every Click, Change Animation Frame

Get help using Construct 2

Post » Fri Jan 30, 2015 3:41 pm

Can someone let me know how I can do the following.

I would like to change the frame of SPRITE 1 ( lets says it has 3 frames) everytime I click some other sprite. So, click one, changes it to frame 1, click 2 to frame 2 and so on.

I see how you can do it for 1 frame, but not how change to another frame, everytime I click on it. Thanks.
B
9
S
2
Posts: 104
Reputation: 1,098

Post » Fri Jan 30, 2015 3:52 pm

On object clicked set animation frame to: (Self.AnimationFrame+1) % Self.AnimationFrameCount <== Put this in the "Frame number" field.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Fri Jan 30, 2015 4:07 pm

@somebody thank you very much. I would have not figured out that string. You knew this from a past need, or just knew what approach to take? Wish I knew this process better.
B
9
S
2
Posts: 104
Reputation: 1,098

Post » Fri Jan 30, 2015 4:16 pm

% is the modulus operator - it's like "remove all of these that fit into previous value" so 4 % 3 is 1. We add to the current frame and if it goes over total frame count that gets subtracted so we never go over.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Fri Jan 30, 2015 4:21 pm

Thank you for the explanation. It works. Again, appreciate the response.
B
9
S
2
Posts: 104
Reputation: 1,098


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests