开发者

Static and moving shapes in spacemanager

Dear all, I have开发者_如何学Python an application that uses cocos2d spacemanager with gravity set to a specific value. If i want to make a shape in the middle of the screen it will fall down to the floor, if i set the gravity to zero all other object will not move as supposed, if i use a second spacemanager and set its gravity to 0 i cant detect collision between objects from different spacemanagers. how can i add a shape that wont fall down in the middle of the screen and detect its collision while other objects behave correctly according to the gravity set. Also a question is, should i use shapes (Circle, rectangle, ... etc) with spacemanager and if i want to use a ccsprite (image) i should put it in a shape or i can use the sprite alone (e.g. a tree is not a rectangle or circle collision and reflection wont be natural how can i do this). regards


Every shape has a property called mass. If you want a shape to be static and respond to collisions just set mass to STATIC_MASS like this:

cpShape *ball = [smgr addCircleAt:cpv(440,70) mass:STATIC_MASS radius:10];

to ad an image, do that:

cpShape *ball = [smgr addCircleAt:cpv(440, 70) mass:STATIC_MASS radius:10];
                [super initWithShape:playerShape file:@"ball.png"];

If this doesn't work, set up a cpCCSprite in it with a shape.

You can search for cpCCSprite on google, im sure you'l find something :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜