Scirra / Construct-feature-requests

A place to submit feature requests and suggestions for Construct.
https://www.construct.net
11 stars 1 forks source link

Condition: Sprite has animation #234

Open brushfe opened 4 months ago

brushfe commented 4 months ago

Reviewed guidelines

Checked for duplicate suggestions

Summary

A new condition for the Sprite object that checks if it contains an animation.

Possible workarounds or alternatives

JS can be used to find this (thanks to @dop2000): www.construct.net/en/forum/construct-3/how-do-i-8/check-sprite-certain-animation-181977

But to average users like myself, JS does feel unnecessary for a simple property check, considering the amount of extensive property checks in other objects and behaviours.

Proposed solution

At minimum, a condition in the Sprite object titled "Has animation".

This would return true (pick) is the sprite has an animation with that name, and false (not pick) if not.

It can also be inverted, like other conditions, to pick sprites that don't have this animation.

Why is this idea important?

The sprite object is a container for animations, so understanding its contents would open up a lot of flexibility and usage for the sprites.

For example, it allows for general code to be applied to a group of sprites, but different animations to be played depending on what the sprite contains (i.e. different damage animations for a group of different spaceships with unique animations).

In families of sprites, alternate actions or animations can be played if a sprite doesn't contain a requested animation (instead of making no change at all, which is the current problem).

It also allows animations to identify sprite objects. instead of adding a variables (selecting all ship sprites with "warp" animations, instead of adding & setting a "canWarp" boolean to every ship sprite object).

Additional remarks

No response

fodi commented 4 months ago

It's hacky, but in some cases the following workaround might also work: hasAnimation.zip

WilsonPercival commented 4 months ago

It's hacky, but in some cases the following workaround might also work: hasAnimation.zip

This is a bad workaround because you change the normal flow of the game. You are changing the animation, which is unacceptable in most games, because... This not only breaks the smooth playback of the animation, but also triggers animation change events.

A slightly better option would be to create a new sprite instance, change its animation, and delete it. But this is still a bad workaround because it triggers the instance creation event.

fodi commented 4 months ago

I completely agree with you, although I did say it was "hacky" and only for "some cases". :)

However it doesn't seem to me that it breaks the smooth playback of animation, the animation change is not visible while previewing the layout (well, on my device).

WilsonPercival commented 4 months ago

I completely agree with you, although I did say it was "hacky" and only for "some cases". :)

However it doesn't seem to me that it breaks the smooth playback of animation, the animation change is not visible while previewing the layout (well, on my device).

It seems you are right. I thought that changing the animation would reset the timer before the next frame plays, but this is not the case.