Jump to content

Tile Sprite.body.setRectangle change sprite's position


woratana
 Share

Recommended Posts

Hello,

 

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.

post-5697-0-58287000-1392180930.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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