Tuesday, February 8, 2011

Corona game continued: Circular Bodies


My first point of reference is obviously the corona docs on circular bodies. All I have to do is define a radius when creating the body.














So with just one line of code:
 physics.addBody(ball, { bounce = 1, radius = (ball.contentHeight /2) - 2})

the physics engine will treat the ball as a circle with a radius that's half the height of its image. I subtracted an extra 2 pixels from the radius to have closer interaction when colliding with other bodies.

Turning on the hybrid physics draw mode we can see that the ball is a circular body and the brick remains a rectangular body.

Next I want to register a collision between the ball and the brick followed by destroying the brick...


No comments:

Post a Comment