Jump to content

Tile Sprite.body.setRectangle change sprite's position


Recommended Posts



I was stuck with this problem since yesterday.


When I create tile sprite, it worked fine:

this.ground = this.game.add.tileSprite(0, 750, 640, 206, 'ground');

the position is X: 0, Y: 750.


But when I tried to setRectangle to make it able to collide with other sprite, I added this code:


this.ground = this.game.add.tileSprite(0, 750, 640, 206, 'ground');this.ground.body.immovable = true;this.ground.body.setRectangle(640, 206, 0, 0);

The tile sprite somehow changed its position to the top of the screen. I have attach the image here.


Please let me know if there is anything I need to know about positioning and making tile sprite collidable.


Link to comment
Share on other sites


  • Recently Browsing   0 members

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