How do I Check the Current Frame of a Sprite

Get help using Construct 2

Post » Sun Jul 31, 2016 7:27 am

Hey there,
I am currently using a sprite object that holds 100+ frames. The sprite is then duplicated 100 times and each instances initial frame is set to 1, 2, 3, and so on. I then use an onTouch condition and I compare the frame of the touched sprite. This then allows me to control some events.

The issue I am having is... I don't feel that this is the most efficient way of handling this type of condition/event. Does anyone have information or suggestions on how to check the current animation frame with maybe a function or reusable line of conditions/events?

Thank You,
Hawkadium

Image
B
56
S
15
G
13
Posts: 826
Reputation: 17,675

Post » Sun Jul 31, 2016 7:33 am

Yep.

On touch -> selectedChampion = current.frame

Lol :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Sun Jul 31, 2016 7:40 am

Ugh, thank you. Sometimes it is so simple, that I completely overlook it.

Edit:
Tested and working.
B
56
S
15
G
13
Posts: 826
Reputation: 17,675

Post » Sun Jul 31, 2016 7:44 am

Yeah it often is really that easy. Over-thinking things can often lead to this type of long-winded event style being made.

If all else fails and you can't do a direct comparison between something (like in your example, animation frame and the sprite set to use) then make a variable for it and compare that.

I have made some seriously complicated stuff happen with only one or two events - it's all about the logical mechanics used to build your idea.

Hopefully when you create your object and set the animation frame you did it using something like "set animation/frame to loopindex" or similar. It would also save a lot of time and be more flexible :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests