How to code charged attacks

Hello reader,

I would like to know how to create a code for charged attacks

Something like this ( The image is just an idea )

How can this be done with defold ?

Thanks for reading

While an action is held down enable a flag (and disable this flag at the end of your update). Then on update if the flag is enabled add the dt value to a counter. If action is released while counter is large enough then make it a charged attack of a power level depending on the size of the counter. If action is released set counter to zero and disable the flag. As action increases, enable extra flags to change the animation state to be more powerful looking, and disable those flags on action release too. You might want interrupts too such as taking damage to clear the flags and counter.

Make sense?

3 Likes

Didnt quite get it, looking up how to use flags now. Will get back to you

Flags are just another way of saying true/false.

animation_charge_1_played = true
animation_charge_2_played = false