Jump to content

Animation not played in Phaser 2.0.1


Recommended Posts



if I reset the sprite in the update-function:

zombie.reset(x, y);

the animation not played:

game.load.spritesheet('zom', './assets/sprites/zombie.png', 132, 158, 6)zombie.animations.add('walk');zombie.animations.play('walk', 15, true);

With Phaser 2.0 it works.


Is now changed somewhat? What do I wrong?


Thank you for reading this.


Link to comment
Share on other sites

This works fine for me, what is it you're trying to do?!

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });function preload() {    game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);}var sprite;function create() {    sprite = game.add.sprite(0, 0, 'mummy');    sprite.animations.add('walk');    sprite.animations.play('walk', 20, true);    game.input.onDown.add(resetSprite, this);}function resetSprite() {    sprite.reset(200, 200);    sprite.animations.play('walk', 20, true);}
Link to comment
Share on other sites

sprite.reset() in the function update why???


I calculate the x/y every second and reset the position - this is for my game logic.


mhm Rich, 


I put the zombie.animations.play('walk', 15, true); after the zombie.reset how you show in the examples. Its not work.



//Zombie zombie = game.add.sprite(100, 100, 'zom'); zombie.width = platform.width / 9; zombie.height = zombie.width * 1.2; zombie.x = platform.x + (platform.width / 2) - (zombie.width / 2); zombie.y = platform.y - zombie.height + 5; zombie.animations.add('walk'); zombie.animations.play('walk', 15, true); zombie.anchor.set(0.5);


//Zombie rotieren zombie.angle += speed;var x = formel;var y = formel;zombie.reset(x, y);zombie.animations.play('walk', 15, true);

With Phaser 2.0 he plays the animation how I created them - with phaser 2.0.1 not.


Thank you for the time to answer

Link to comment
Share on other sites

I think his question was more "why are you resetting the sprite" rather than just changing its x/y coordinates?


A sprite reset will reset the world position, local position, alive, exists, visible, renderable flags, out of bounds flag, health, physics body and cause a cache refresh. This is not something you want to be doing in a main update loop surely??!

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...