I’m working on a 2D fighting game, and if you’re familiar with the genre (Street Fighter, Mortal Kombat, etc.), every attack animation in these games consist of 3 stages:
Start-Up > Active > Recovery
This is important because only the “active” frames cause damage to opponents. (Example: the full extension frames of a kick animation - if it hits an opponent earlier, it’s both “unfair” and also looks incredibly odd because the opponent would be hit before the foot even touches them.)
In Defold, the hacky way I’m currently implementing this is:
- player input triggers a “play_anim_startup” animation using sprite.play_flipbook – the complete function then triggers…
- a “play_anim_active” function, which changes state to do damage to opponents and shows the “Active” frames using sprite.play_flipbook which then triggers…
- a “play_anim_recovery” function, which changes state back to not doing damage.
It “works” but as you can imagine, it’s also incredibly cumbersome as the move set grows in this project since each and every attack is represented in a sprite atlas as “attack1_startup” (with only its startup frames), “attack1_active” (which only its active frames), and “attack1_recovery” (with only its recovery frames.)
In other words, every attack animation consists of three animations.
I’ve looked at some other projects in similar genres like the “Slasher” project in the asset portal and the “Librarian Barbarians” fighting game, but after hours of studying the source code of those projects, I can’t seem to understand what exactly they’re doing to achieve this without splitting every attack animation into three separate animations.
I’ve also searched every term I could think of here that could address this but didn’t find a clear indication of what approach to take with this.
Most of my experience has been on other engines and I’m still new to Defold, so I apologize if the approach I’m searching for is incredibly obvious and trivial.
Any help would be greatly appreciated!