开发者

Set limit for b2Body class object moving in coco2d iPhone application

开发者 https://www.devze.com 2023-02-23 16:33 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号