Jump to content

Collision inside rectangle


efusien
 Share

Recommended Posts

Hi,

 

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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