how can i access frame data?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LJ INFINITY

so i want to add attack feature to my game and i want to access the frame data in animated sprite, is there a way?

You must have added a AnimatedSprite node to you scene right ? Like if you have a Player Scene then maybe you added AnimatedSprite node to it.
You can simply access this node and specific animation you created using it in your Player Script like this :


Of course I have assumed you named your animation “attack”.

Scavex | 2021-04-24 09:37

yes, but how do i take frame data like, to do damage at a specific frame

LJ INFINITY | 2021-04-24 15:28

:bust_in_silhouette: Reply From: mamalak

no there’s no way for animatedsprite
use animationplayer instead.

actually there is but tnk u anyways

LJ INFINITY | 2021-04-25 06:30

:bust_in_silhouette: Reply From: exuin

If you just want to detect which frame is the current frame, AnimatedSprite has a frame property and a frame_changed() signal. If you actually want to get the data from the frame, you must call get_frame() on the frames (type SpriteFrames) property of the AnimatedSprite.

If you want to deal damage at a specific frame, it may be easier to use an AnimationPlayer and call the function to deal damage in the animation track instead.

sorry im new and dont know some stuff so is there like a reference or a video explainig this

LJ INFINITY | 2021-04-24 16:54

You can look at the documentation, I guess. Sorry, that’s really all I look at.

exuin | 2021-04-24 17:00

tnk u for your help

LJ INFINITY | 2021-04-25 06:28