Hi everyone,
I'm making an iPad game using box2d.
In the game, you drag disks with your finger inside a polygon shape.
To make the disk you selected follow your finger but still have physics react properly, I'm setting a velocity for the disk toward the finger position.
However, my problem is that if you touch outside the wall boundaries of the polygon shape representing walls, the disk keeps smashing in the walls infinitely.
To stop this, I want to simply not draw the disk if the position I touch would have caused the disk position on it to be outside the polygon shape or overlap it.
Is there a simple way to do it via the box2d api?
My other option is to calculate this mathematically, but I'm trying to avoid that since I'm sure box2d knows how to calculate these things.
Note that the polygon edges are static and never change, and that I want to know basically if the disk (a circle) is completely within the polygon based on the center position and its radius.
I've tried create a demi-body and checking for collision via the b2ContactListener interface, but the problem is that I want to know immidiately if this is the case and the listener is being called only after my function is done, and a Step is being run...
Thanks!
Idan
I'm making an iPad game using box2d.
In the game, you drag disks with your finger inside a polygon shape.
To make the disk you selected follow your finger but still have physics react properly, I'm setting a velocity for the disk toward the finger position.
However, my problem is that if you touch outside the wall boundaries of the polygon shape representing walls, the disk keeps smashing in the walls infinitely.
To stop this, I want to simply not draw the disk if the position I touch would have caused the disk position on it to be outside the polygon shape or overlap it.
Is there a simple way to do it via the box2d api?
My other option is to calculate this mathematically, but I'm trying to avoid that since I'm sure box2d knows how to calculate these things.
Note that the polygon edges are static and never change, and that I want to know basically if the disk (a circle) is completely within the polygon based on the center position and its radius.
I've tried create a demi-body and checking for collision via the b2ContactListener interface, but the problem is that I want to know immidiately if this is the case and the listener is being called only after my function is done, and a Step is being run...
Thanks!
Idan