Search code examples
ipadcocos2d-iphonechipmunk

Making a Sprite unmovable...[Chipmunk & Cocos2D]


Im using Chipmunk with Cocos2d to make a gravity based puzzle game, however I have reached a part of my project whereby I need a sprite that once drawn does not move and cannot be moved by the other sprites within the environment.

In essence...

Can I create a static (non moving) sprite that is not affected by in game gravity or other objects in the game.

Thanks in advance I've only been doing this project a week....


Solution

  • Yes, this is possible.

    1) Create a body with infinite mass and moment.

    2) Do not add the body to the space.

    3) Create the desired shape.

    Use cpSpaceAddStaticShape to add the shape to the space.