How do I transform a sprite while playing? For example when Mario gets a fire flower he turns into Fire Mario and can now shoot fireballs.
You can use sprite's animations and variable.
Edit your sprite, add another animation (with some Fire Mario frames).
In event sheet, when transform is on, set your sprite's animation to the good one. Then set a sprite's variable to 1 if needed to detect the transform.
If press fire button and this variable is 1 ==> launch fireball !
Develop games in your browser. Powerful, performant & highly capable.
Thanks. Now what if I wanted the transformation to last a limited amount of time?
I'm not sure it's the best method but you can do a thing like this:
Add a global variable (called "timer" for example).
Add en event: Every tick and transform variable = 1, add value dt (not set!) to "timer". Why ? Because sum of dt = 1 every second (deltatime tuto).
So if you want to stop transformation after X seconds, check every tick if "timer" >= X. If true, set transform variable to 0.
or maybe this, better and simpler but dunno if it works:
when transform variable is set to 1, add two other actions : wait X seconds, and set transform to 0.
it works ! find here a very simple example:
T to transform, Space bar to fire.