Collision detection without defining polygon?

Recommended Posts


I am fairly new to the phaser framework. So please excuse my noob ignorance if this is an easy question. I know that adding collision on a object such can be easily done with:

game.physics.arcade.collide(gameObject1, gameObject2, collisionCallback, processCallback, context); 

However when you have an object like this ice spike:
You would likely need to define a polygon in order for proper collision detection. Which should theorectically be pretty easy considering it's pretty much a triangle.

My question is however... when I get into more unique elements say for example this water:

And I want to make only the non-transparent parts collide. Is there an easier way?
Is there a way to detect non-transparent pixels as opposed to defining each aspect by hand?

Hope this makes sense & thanks so much in advance!


Share this post

Link to post
Share on other sites
Not in Arcade Physics I'm afraid. Arcade is based on 'AABB' collision detection, which stands for Axis Aligned Bounding Box - basically all objects have a non-rotatable rectangle collision area, which is very fast, but obviously has limitations here. Often a tradeoff is made when trying to apply rectangles to triangular objects whereby the body size is reduced to provide coverage over the part of the triangle that matters.


If you really need non-rectangular collision bounds, you're going to have to use P2 physics instead of Arcade. Then you can define arbitrary simple polygons as collision hulls.

Share this post

Link to post
Share on other sites

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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.