STuFF Posted January 6, 2014 Share Posted January 6, 2014 Hello, I'm trying to do something easy, and I did it very quickly with Phaser, that framework is really awesome I made a big ball (a sprite) bouncing in the game world, then I added some "platforms" in the middle of the world (some sprites too) then everything was ok. The ball bounced on the edges and on the platforms. BUT. My ball is a circle (obviously) and my platforms are rectangle, so, in some case, the collision is not accurate, see example below : I'm using this.game.physics.collide(); to test collision. I tried to use the processCallback to test the collision precisely using Phaser.Circle.intersectsRectangle() which is very easy to achieve, but the "bounce" already occured at this time. I don't know what to do next, I don't know if I'm on the right way. Of course, I don't want to use an overkill physic system like box2D or whatever else... Can someone could help ? thanks Link to comment Share on other sites More sharing options...
rich Posted January 6, 2014 Share Posted January 6, 2014 The way you'd do it would be to use body.customSeparateY on the circle and then in your processHandler you can check the circle / rectangle intersection. However the problem is that with a large circle/rect (as in the image above) the circle body will only pass the 'collide' test for the first few iterations, depending on speed, after which it just becomes 'embedded' and the two rectangles are no longer considered to be 'colliding' but are instead overlapping. Of course the problem is that you want it to carry on thinking it's colliding right up until the Circle itself does actually intersect, but that's just not how it works at the moment :-/ Link to comment Share on other sites More sharing options...
STuFF Posted January 7, 2014 Author Share Posted January 7, 2014 Thanks Rich for the explanation. I think I will stick to simple rectangle collision for now. Link to comment Share on other sites More sharing options...
Tarion Posted January 8, 2014 Share Posted January 8, 2014 Is there any good reason why overlapping does not trigger the collision? Or can it be refactored to do so without breaking any/some existing games? Link to comment Share on other sites More sharing options...
Recommended Posts