Faizy Posted May 5, 2017 Share Posted May 5, 2017 Hey, I have a spritesheet which has different sizes for each sprite(like this one for example, as you can see they are differences in the size of each frame ). Let´s assume I have a spritesheet called "running" and one called "jumping", the first one is 50x50 and the second one is 50x70. Since they have different sizes, I added them separately into the game. Both animations work fine. The problem I have now is, that I see every spritesheet all the time, since I have to add them into the game, meaning all the animations/different spritesheets are overlapping. 1. Is there a better way to solve the Problem of different sized spritesheets? 2. What would be a good solution to my problem? Thank you and have a nice weekend Link to comment Share on other sites More sharing options...
Andromedus Posted May 5, 2017 Share Posted May 5, 2017 Just hide the sprite that's not in use and show the one that is: jumping.visible = false; running.visible = true; And if the different animations have different widths, use the anchor property to align them, eg to align them centrally: jumping.anchor = new Phaser.Point(0.5, 0.5); Also, it's probably a good idea to add each sprite to the same Phaser.Group. That way you can just move and rotate the whole group rather than each individual sprite. Faizy 1 Link to comment Share on other sites More sharing options...
Faizy Posted May 5, 2017 Author Share Posted May 5, 2017 Thank you. I already thought about that option, but I thought it would cost to much performance. Any example(code) where this was archieved? Link to comment Share on other sites More sharing options...
Andromedus Posted May 5, 2017 Share Posted May 5, 2017 Another option which might be simpler is just to change the sprite texture: https://phaser.io/examples/v2/animation/change-texture-on-click Link to comment Share on other sites More sharing options...
Recommended Posts