How do I Animation set +1

Get help using Construct 2

Post » Wed May 24, 2017 5:22 pm

I want to use the mouse wheel and scroll up + 1 then at the end of the animation frames I want it to go back to 0

Basically, use the Mouse wheel for scrolling through animations and loop
B
48
S
33
G
19
Posts: 58
Reputation: 14,217

Post » Wed May 24, 2017 5:43 pm

Add variable called current frame set it 0 on start. Add new event mouse -> mouse wheal down, add action to the event sprite -> set animation frame = frame(global variable), another action system -> add to -> frame -> 1.

Also see how many frames the animation has and add event to reset the variable frame to 0, when the last frame is reached.

You can change this event with mouse while up, and decrement the frame by -1, so with mouse while down it will scroll the animation forward, and with mouse wheal down it will decrement them.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,357

Post » Wed May 24, 2017 7:12 pm

You actually don't even need an extra variable.
Each Sprite has its own expression [Sprite].AnimationFrame which returns the current animation frame.
It also has the expression [Sprite].AnimationFrameCount which can come in handy.

Now when you want to scroll through the animation frames, you can do this with one action:
  • Set animation frame to: Sprite.AnimationFrame < Sprite.AnimationFrameCount-1 ? Sprite.AnimationFrame+1 : 0

This will include the animation frame check condition in the actual action.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests