SirGrassy Posted June 1, 2017 Share Posted June 1, 2017 Hello! Im new here, and I'd like some help. I was coding, made a new spritesheet and tried making it play while I press a key. It doesn't seem to be working, and I don't know why. If you could help in any way, it'd be greatly appreciated. Thanks! CODE - https://pastebin.com/Sciaw2uY SPRITESHEET - Link to comment Share on other sites More sharing options...
jpdev Posted June 2, 2017 Share Posted June 2, 2017 Hi, I think the problem was that you redefine the animations every frame and phaser doesn't like this. Here is your example working: http://jppresents.net/static/examples/walk/ Here is the slightly changed code: http://jppresents.net/static/examples/walk/walk.js I move the animation creation to playerInit (and added a single frame stand animation). Ignore the changes in preloadImageAssets, that was to fit my image files. Edit1: There is another small problem with your code, If you walk in two direction (up & right) at the same time, your code switches the animation from up to right every frame - this way the animation never advances to the next frame. You should restructure getPlayerInput() in a way that manages to only call one player.animations.play() at the end. You could create a variable in which you set the animation name during the key checks and then at the end call play with that value. Edit2: I changed the animation settting like I suggested in Edit1. Link to comment Share on other sites More sharing options...
SirGrassy Posted June 2, 2017 Author Share Posted June 2, 2017 Wow, thanks for the help! I greatly appreciate it. Have a nice day! jpdev 1 Link to comment Share on other sites More sharing options...
Recommended Posts