Sanic Posted August 13, 2016 Share Posted August 13, 2016 Maybe I've misunderstood how groups work... I was trying to set up a sprite(paddle) that would collide with the world bounds inside a container(board) that I could move and have the sprite's position be relative to the container. I got the sprite to go where I wanted but the collision rectangle... not so much. The collision works, just it's not where the sprite is... Here's the relevant code: this.board = game.add.group(); this.board.paddle = game.add.sprite(0, 0, 'paddle'); game.physics.p2.enable(this.board.paddle,true); this.board.add(this.board.paddle); this.board.paddle.body.setRectangle(64, 16); this.board.paddle.body.fixedRotation = true; this.board.paddle.rot = false; this.board.paddle.prev = 0; this.board.x = 300; this.board.y = 100; In addition, when I rotate in the update with: this.board.paddle.body.rotateLeft(200); The sprite and the hitbox both rotate, but don't align after a while. I'm using Phaser 2.6.1 and with P2 physics started. Can anyone help me keep my sprites and hitboxes aligned? Link to comment Share on other sites More sharing options...
Recommended Posts