SimplyKiwi
SimplyKiwi

Reputation: 12444

How to simulate gravity for CCSprite?

Currently I am using UIKit in my app but I decided to make the switch to Cocos2D, right now I am trying to implement gravity but I am having trouble doing so. I have googled this and have not found much about it. Anyway is there any way of doing this?

Would anyone like to share what their doing to have a CCSprite have gravity? I really have no idea where I should even begin on how to do this!

Thanks!

Edit1: I am now using this code:

// Create a world
    b2Vec2 gravity = b2Vec2(0.0f, -5.0f);
    bool doSleep = true;
    _world = new b2World(gravity, doSleep);

For simple y vector gravity. My question is, how would I apply this code to my CCSprite?

Upvotes: 0

Views: 371

Answers (1)

slycrel
slycrel

Reputation: 4285

Generally speaking people use physics engines to get this done. Chipmunk and Box2d are both bundled with cocos2d and can help here, no need to reinvent the wheel.

Upvotes: 2

Related Questions