RafaelBarbosatec / bonfire

(RPG maker) Create RPG-style or similar games more simply with Flame.
https://bonfire-engine.github.io
MIT License
1.22k stars 188 forks source link

[question]: How to play sound on animation start? #537

Closed dvmatyun closed 2 months ago

dvmatyun commented 3 months ago

How can we help?

How do I play some sound effect when movement animation starts? (on each loop) So imagine you have a sprite sheet of walking man, and you want to play footstep sound effect each time the foot hits the ground (and imagine it is the first frame in spritesheet). PS Im talking about this in context of enemies, so SimpleEnemy \ Enemy \ DirectionAnimation classes

RafaelBarbosatec commented 3 months ago

Hi @dvmatyun . You can do override the 'onMove' method and try look to the frame animation index . or put a interval. In new version you can get this with animation.currentIndex or animation.fastAnimationcurrentIndex.

dvmatyun commented 3 months ago

@RafaelBarbosatec for some reason both _current and _fastAnimation animations are private. Guess I will just fork the implementation and make getters for them. Anyway, thanks!

RafaelBarbosatec commented 3 months ago

The new version it is public. Didn't? You need access the index and not the entire animation