Omar HossamEldin
Omar HossamEldin

Reputation: 3111

Fire event when reach certain angle in revolute joint

I need to develop cannon game using box2d and cocos2dx. Cannon is divided into two parts

I have searching in SO and i found This Solution which calculates the angle each step, this can be used but it needs more calculations that i feel lazy to do.

Does the callback method for notifying motor speed or certain angle has been reached exists ?

Upvotes: 0

Views: 88

Answers (2)

DylanVann
DylanVann

Reputation: 493

All a callback would do behind the scenes is check the angle each frame and then call the callback function when the joint angle is within a certain range.

There's no built in callbacks for this use case. You could make your own to hide what's going on, or you could just put the if statement in the update function. The performance of this will be fine.

Upvotes: 0

pdeschain
pdeschain

Reputation: 1421

Schedule a function to check your conditions on each frame. When you don't need the checks any more - unschedule the selector, then reschedule when needed again. As far as I know there are no callbacks for your exact task.

Upvotes: 0

Related Questions