Jump to content

Collision inside rectangle


Recommended Posts



I want my player sprite to move only inside a restricted area inside the game world.

This area is a rectangle.


Is there a way to set like mySprite.body.collideWorldBounds = true, but inside such a rectangle ?


A solution is to have 4 sprites for each rectangle side, and collide with my player sprite.

But doesn't sound good, eh ?

Link to comment
Share on other sites

Thanks guys.


I tried this code:

game.physics.arcade.setBounds(0, 0, 200, 200);

The player stays in this 200 x 200 area. Good!

But in my case I want the player to go outside this area on some conditions. Like drag and drop the player to another area.

So in this case I have to make my own bounds conditions.


I'll try to extend the sprite like lewster32 said.


If you have any example with preUpdate method, let me know  :rolleyes: 

Link to comment
Share on other sites

  • 11 months later...

  • Recently Browsing   0 members

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