blackgames Posted March 26, 2014 Share Posted March 26, 2014 Hallo, 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 More sharing options...
JP91 Posted March 26, 2014 Share Posted March 26, 2014 sprite.reset() in the function update why??? Link to comment Share on other sites More sharing options...
rich Posted March 26, 2014 Share Posted March 26, 2014 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 More sharing options...
blackgames Posted March 26, 2014 Author Share Posted March 26, 2014 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. Create://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);Update://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 More sharing options...
rich Posted March 26, 2014 Share Posted March 26, 2014 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 More sharing options...
blackgames Posted March 27, 2014 Author Share Posted March 27, 2014 of course it is definitely easier to put the x/y directly with zombie.x & zombie.y sorry I thought the reset would be the only way - I still have so much to learn Link to comment Share on other sites More sharing options...
rich Posted March 27, 2014 Share Posted March 27, 2014 Me: to Link to comment Share on other sites More sharing options...
Recommended Posts