barodapride Posted January 18, 2014 Share Posted January 18, 2014 Hello, what is the correct way to move a sprite? Do I do sprite.centerOn(x,y)? That doesn't seem to move the sprite.body...Do I modify sprite.body.x (never mind that's read only). Do I modify sprite.body.center.x/y? That doesn't seem to affect sprite.body.x. Why is something so basic causing me such grief? Link to comment Share on other sites More sharing options...
Heppell08 Posted January 18, 2014 Share Posted January 18, 2014 Sprite.body.velocity.x = 250;That moves the sprite along the X axis. Link to comment Share on other sites More sharing options...
toto88x Posted January 18, 2014 Share Posted January 18, 2014 Or simply sprite.x = 42; sprite.y = 42; or even sprite.reset(42, 42); Link to comment Share on other sites More sharing options...
barodapride Posted January 18, 2014 Author Share Posted January 18, 2014 I know how to make it move by setting the velocity or changing sprite.x/y but there are some really goofy details between the sprite and it's body that have caused me some headaches. Link to comment Share on other sites More sharing options...
mamwalter Posted January 30, 2014 Share Posted January 30, 2014 i have a similar question. What is the best method to comand to a sprite to move to a (x,y) location. i first use something like this: this.game.add.tween(this.sprite).to({ x: x, y: y}, 10000, Phaser.Easing.Linear.None, true); works but i would like to use the facing propertie of the body. Should a use Sprite.body.velocity.x / velocity.y and test position on each update? an other solution ? thanks Link to comment Share on other sites More sharing options...
Recommended Posts