Set limit for b2Body class object moving in coco2d iPhone application
I have one object of b2Body class. But I was it to move just say 25% of the screen from bot开发者_开发知识库tom. But it keeps moving though i set boundries.
Another option was to use setPosition once i reach that condition but in documentation this method exists but while implementation it throws error.
Can anyone please help?
Thank you,
Ankita
Here's a great tutorial that explains the basics of box2D demonstrated using cocos2d for drawing. It specifically shows how to make physical boundaries for the screen, which i think is a better way of achieving what you want to do than "interfering" with the box2d world by setting positions and forces directly.
You can just add CCColorLayer and put b2Body into it. It will move for that layer only. You can give x,y, heigh and width for layer.
精彩评论