BdR Posted May 28, 2016 Share Posted May 28, 2016 See fiddle here:https://jsfiddle.net/krrgLkqL/ I'm working on a game with tilemaps and arcade physics etc. and I'm running into an issue. I've got a sprite sheet of a running guy and the physics body rectangle is adjusted, so the physics.body only covers the torso of the sprite guy. player.anchor.setTo(0.5); player.body.setSize(30, 56, 10, -3); // width, height, offsetX, offsetY The sprite is always facing right and when the player moves to the left, I just flip the scale.x to -1 So something like this: if (_cursors.right.isDown && player.body.velocity.x >= 0) { // move right player.body.velocity.x = MOVE_SPEED; player.scale.setTo(1, 1); // flip to right } else if (_cursors.left.isDown && player.body.velocity.x <= 0) { // move left player.body.velocity.x = -1*MOVE_SPEED; player.scale.setTo(-1, 1); // flip to left }; The problem is that when the player faces left, the body is outside of the sprite, the body and the sprite don't overlap anymore which screws up the collision detection. Any idea how to solve this? Link to comment Share on other sites More sharing options...
Milton Posted May 28, 2016 Share Posted May 28, 2016 https://github.com/photonstorm/phaser/issues/2488 BdR and VitaZheltyakov 2 Link to comment Share on other sites More sharing options...
VitaZheltyakov Posted May 28, 2016 Share Posted May 28, 2016 Use Phaser 2.4.9 (dev) BdR 1 Link to comment Share on other sites More sharing options...
BdR Posted May 30, 2016 Author Share Posted May 30, 2016 Thanks, using the newest Phaser dev version solved it. Umz 1 Link to comment Share on other sites More sharing options...
Umz Posted May 30, 2016 Share Posted May 30, 2016 Ah damn, I had to offset the body x to the width of the Sprite when I flipped it. Could have just upgraded the engine! Link to comment Share on other sites More sharing options...
Recommended Posts