Set current animation frame to +-1

Get help using Construct 2

Post » Fri Jul 27, 2012 12:59 am

How do I setup a sprite with a single animation that's going to change frames, previous or next, by one frame when a key is pressed?
B
13
S
4
G
2
Posts: 26
Reputation: 2,429

Post » Fri Jul 27, 2012 1:07 am

Put a "Compare frame" event as a sub-event of your "On key pressed" event, set the frame to 1 if the frame is currently 0. Then add an "Else" event (press x) and set the frame to 0 in the in that event.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jul 27, 2012 2:53 am

OK, now I can go back between two frames but I've got 183 of them. Is their a way to say set current animation frame to current animation frame + 1?
B
13
S
4
G
2
Posts: 26
Reputation: 2,429

Post » Fri Jul 27, 2012 2:57 am

Sure, just use "Sprite.Animationframe+1" when setting the frame.

I just realized that's what you really wanted, sorry for the misunderstanding!

Edit: Oh, and if you want to do either +1 or -1 randomly, you can use the choose expression "Sprite.Animationframe+int(choose(-1, 1))"
Nimtrix2012-07-27 03:03:53
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jul 27, 2012 3:18 am

Awesome it works now, thanks!

Ive got a lot of other questions I wanna ask, should I start up another topic for each(if I can't find one), or a general topic? Is their a chatroom to ask questions? I noticed the current one isn't working.

Again Thanks!
B
13
S
4
G
2
Posts: 26
Reputation: 2,429

Post » Fri Jul 27, 2012 3:25 am

Depends, if it's a similar question you can just post within the same topic. There's an IRC chat room, you can connect with an IRC client, or through Mibbit with the "Chat!" link in the menu. The "Chat Beta" is part of the forum and doesn't really work, like you saw.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jul 27, 2012 8:01 am

"Sprite.AnimationFrame+1 %Sprite.animationFrameCount" To make it loop back round to 0
B
28
S
8
G
1
Posts: 469
Reputation: 4,683


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests