ricardocouto8 Posted December 18, 2013 Share Posted December 18, 2013 Hello everyone, I started using Phaser today and I must say I am impressed. Well done guys! I made a simple image rotate and move towards the mouse, as explained in the examples "accelerate to pointer" and "move towards object". What happens though is that when that image collides with the mouse (meaning image coordinates = mouse coordinates) the image stops and starts trembling awkwardly. Any way to make it stop facing the last position before colliding? My code:var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });function preload() { game.load.image('player', 'assets/player.png');}function create() { player = game.add.sprite(400, 300, 'player'); player.anchor.setTo(0.5, 0.5);}function update() { if (game.physics.collide(player, this.game.input.activePointer.circle)) { player.velocity.x = 0; player.velocity.y = 0; } else { player.rotation = game.physics.moveToPointer(player, 60, this.game.input.activePointer); }}Thanks! Link to comment Share on other sites More sharing options...
rich Posted December 19, 2013 Share Posted December 19, 2013 Hi - the problem is that collide won't work with Sprite vs. a Circle object, so the velocity will never be reset which means it will carry on moving to the pointer, which will be like tiny amounts (probably 0.x of a pixel) causing the stuttering. What I would suggest is you can either use activePointer.circle.contains(sprite.x, sprite.y) or you could position a sprite on the pointer and then use collide against that (you can set it to renderable = false to stop it displaying if you need). Tanner 1 Link to comment Share on other sites More sharing options...
ricardocouto8 Posted December 28, 2013 Author Share Posted December 28, 2013 Thanks rich for the quick reply Problem solved! Link to comment Share on other sites More sharing options...
Recommended Posts