1
\$\begingroup\$

I'm developing a application in cocos2d using the Box2D framework, but unfortunately I am having issues. I'm not able to restrict the orange ball in the half screen area, taking the image below as reference, I don't want to allow the ball to go to the opposite part of the screen.

I'm using the b2MouseJoint to move the ball around the screen. b2PrismaticJointDef seems to restrict on any particular axis, but I need to restrict on a particular rectangular area of the screen.

i want to prevent orange color ball to move within displayed screen not the other part of the screen

\$\endgroup\$
1
\$\begingroup\$

I Did This By following simple if Condition It was looking hard to Me As I am new to the Box2D FrameWork

if (location.y<240.00)
{
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
    _mouseJoint->SetTarget(locationWorld);  
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.