Jump to content

Collide of two Object ?


nExt
 Share

Recommended Posts

Hello i have problem..

i write function check event collide of two object ..

 

example :

 

game.physics.arcade.collide(ball, paddle);

the square contain ball and have transparent background.

 

so I want to know is the ball (circle) collides with a paddle or square (containing balls) collide with the paddle ??

 

ps: i need check collide the ball(circle) collides with paddle...

Link to comment
Share on other sites

sorry.. i would really like to help you but i'm honestly not sure i understand your question :/

 

if you want to activate collisions between a ball and a paddle your example is correct..  as long as you enabled arcade physics on those objects they will collide...

 

arcade physics doesn't know circles .. physics bodies in arcade physics will always be rectangles..  if you need circles you should use p2 physics

Link to comment
Share on other sites

sorry.. i would really like to help you but i'm honestly not sure i understand your question :/

 

if you want to activate collisions between a ball and a paddle your example is correct..  as long as you enabled arcade physics on those objects they will collide...

 

arcade physics doesn't know circles .. physics bodies in arcade physics will always be rectangles..  if you need circles you should use p2 physics

yes.. sorry my english not good..

 

My question is : when the collision between two objects. then the collision is calculated between the two images containing between 2 objects or the visible part of the object (eg a ball image as it will have a transparent background.)

 

 

what is :  p2 physics

Link to comment
Share on other sites

P2 is an additional physic system to arcade: http://docs.phaser.io/Phaser.Physics.P2.html.

Because arcade has no idea of circles, collision detection is based on AABB (rectangular) only.

If you want to use collision detection between a circle and another object, you have to use P2, or write you own functions.

For examples of P2, check http://examples.phaser.io/ (has it own section) or use the forum search.

Link to comment
Share on other sites

What I read out of his question is, that he want an auto-generated polygon by the transparent parts of an sprite.

For all I know, this is not possible with phaser (and I guess it never will be).

 

Like the other replies already said: use p2-physics and use either your own polygons or the default ones (for example circle).

 

Loading your own (custom) polygon:

http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=load+polygon+2.js&t=load%20polygon%202

 

For default polygons: (the ship is a circle and the pandas are rectangles)

http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=collision+groups.js&t=collision%20groups

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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