How to detect stack objects falling down
In my game, Objects are falling down and I have to catch that object a开发者_如何转开发nd have to create a stack. I am doing this by using chipmunk physics engine. I am able to create stack but I don't understand how to detect that stack is falling like "Tower Bloxx" game.
If any one knows it please help me out.
You need to calculate the forces and torques on each object.
Gravity acts on the center of mass of an object. If this object overhangs another object, then there could be a torque that could roll the object off.
If you've got the physics down so that it's realistic, then you can detect whether the stack is stable or not by monitoring the direction of the velocity for each object. If it's changing sign, and the magnitude is getting smaller, then it's stabilizing. (If it's zero, it is stable already.)
I'm not familiar with the structure of the chipmunk engine, but does it have some sort of collision event? If so, you could use that event to detect when any block but the base one hits the ground object and end the game then.
精彩评论