Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 1 down vote accepted

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);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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