I want to exchange my sprite's image based on events. I want to avoid destroying my sprite object and spawning a different one in order to not lose its behaviors and variables. Is there functionality for this or do I need a different approach?
Develop games in your browser. Powerful, performant & highly capable.
easiest way is by setting up different animations for the sprite. based on the event, just change the animation to be shown.
that seems like an easy solution, thanks. however ideally I'd like to ben able to apply external sprites, like say the same sprite I'm colliding with, referencing that same image file. Is there a way to do that, referencing another sprite to switch to?
I'm not sure if I understood of what you try to achieve.
Do you mean:
You have one sprite that you control and when you collide with that sprite at another sprite your sprite will have the same image as the other sprite?
yes, pretty much. although I'd should not need to be that exact same one I switch to, Just switching to some other image, presumably refrenced through another sprite object. say my player sprite collides with some npc sprite, upon which he takes on a different image. that different image I'd like to be able to reference differently than by switching to a different preassigned animation, I'm guessing that there might by a way to reference the image of another sprite somehow..?