Access Frame Number of an Animation

Just started using Construct 2? Post your questions here

Post » Thu Feb 02, 2017 6:01 am

Is it possible to access the internal frame number of the animation? Animation is on 0, 1, 2, 3rd frame etc.

I did some Google searches, but nothing really came up.

I needed to do something so it was pretty easy with a global variable and breaking up the animation into individual frames.

It works. Not sure if that's the best, most efficient, or the only way to keep track of frame numbers of a specific animation for conditions.

I've see people adding frame number as an instance variable when working with a sprite strip and a mask, but it's not something that would work for me here.
B
37
S
20
G
18
Posts: 259
Reputation: 12,922

Post » Thu Feb 02, 2017 6:12 am

You can get the animation frame number easily (there's an action which returns the current AnimationFrame) but I'm tired so I'm probably missing what you're wanting to do. What are you trying to do with it?
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Thu Feb 02, 2017 5:20 pm

Oh, hi there.

Basically, I was just doing a ship tilting animation when pressing arrow keys left and right and I wanted it to animate back when the arrow key was released. I coded something with variables that works flawlessly while breaking up the 29 total frame animation into individual frames linked up to a specific variable (my way of keeping track of the frame number).

I decided that the default standing still animation was too boring, so I also decided I would have the ship rocking back and forth by itself in the default position once it animated back to default. That's where my logic got a bit hung up. I'm pretty sure now that with this sort of scenario you can only have 2 logical conditions: key pressed and key released, so I gotta add the default rocking animation to the key released logic. That's when I got hung up on an infinite loop (since I've never done one), but someone posted a solution already, so I'll give that a try today.

P.S. I found that working out the logic with Excel and then just coding with text objects works great.
B
37
S
20
G
18
Posts: 259
Reputation: 12,922


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests