nExt Posted April 28, 2014 Share Posted April 28, 2014 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 More sharing options...
valueerror Posted April 28, 2014 Share Posted April 28, 2014 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 nExt 1 Link to comment Share on other sites More sharing options...
nExt Posted April 28, 2014 Author Share Posted April 28, 2014 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 physicsyes.. 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 More sharing options...
Heppell08 Posted April 28, 2014 Share Posted April 28, 2014 Its hard to answer what you mean but if you want a swing function to do variable velocities on hit then maybe you'll need a few more variables and a collision callback to calculate the velocities and angles.That is if that's what you require nExt 1 Link to comment Share on other sites More sharing options...
marvster Posted April 28, 2014 Share Posted April 28, 2014 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. nExt 1 Link to comment Share on other sites More sharing options...
Taleforge Posted April 28, 2014 Share Posted April 28, 2014 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 nExt 1 Link to comment Share on other sites More sharing options...
Recommended Posts