Search code examples
javascriptpluginsspriteassetsphaser-framework

How to load sprite png on moves


For example, I have idle sprite and I have another files PNG where character is moving, so I need to change sprites on move and if yes how to do something like that(I have also asprite file but IDK how to use it, or IDK I must need plugin to load that) PS i make that on phaser

I try do load without plugin but that doesn't work


Solution

  • Basically you would do the same for the moving sprite as for the idle animation. if you have multiple files, you would have to load all of them on preload (with different keys), generate the animations, and when you want to play the animation just call the play function on the sprite.

    For details how the single steps work, check out this official example, it shows all steps needed. Execpt the loading from multiple file, but that is just adding one extra load line in the preload function

    btw.: For more details with sprites checkout these animation/sprite examples, there all pretty good, and cover many different topics issues.