Jump to content

Hitbox and Sprite not aligned when group moved? (P2)


Recommended Posts

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');		
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:


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


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...