Gravity?

This topic contains 5 replies, has 3 voices, and was last updated by  lerkan 2 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
Author Posts
Author Posts
September 30, 2011 at 10:46 pm #235717

Objective Zero
Participant
@objective-zero

In my game, I am using Cocos2D for the Game part. I am now trying to implement gravity but I am hearing that I have to use Box2D or Chipmunk. I could use those but is there any way to do this in Cocos2D, can anyone share any ideas/code just so I can add some simple gravity using Cocos2D if possible?

Thanks!

September 30, 2011 at 11:01 pm #349703

skyhawk
Participant
@skyhawk

yes, there is nothing preventing you from modifying object’s position and implementing basic acceleration->velocity->position updates.

Iterate your objects, update their velocity based on some global gravity vector, update their positions based on their velocity.

That being said, you’ll probably want other physics like features besides just gravity, and honestly you’ll just save yourself a shot foot if you learn Chipmunk.

September 30, 2011 at 11:04 pm #349704

Objective Zero
Participant
@objective-zero

Actually, my game doesn’t have anything else besides gravity that has to do with Physics. I only have one object that is going to be affected by gravity. That being said, should I do with Cocos2D and if so, where would I begin?

Thanks for the help!

October 1, 2011 at 2:06 am #349705

skyhawk
Participant
@skyhawk

Your question doesn’t make sense

October 1, 2011 at 2:13 am #349706

Objective Zero
Participant
@objective-zero

Ok so pretty much I am making a game similar to Doodle Jump, only gravity is involved. There is no advanced physics with objects colliding or anything like that. So in my game I just need gravity and no other advanced Physics engine. So I am debating whether or not whether to actually use Box2D or Chipmunk but it seems that I shouldn’t since I don’t need any advanced Physics. So this leaves me with doing gravity via Cocos2D, but I am not sure where I should go to do this. I just need simple gravity when jumping/falling and no gravity when on a platform. But like I said, where should I begin to implement gravity using only Cocos2D?

October 1, 2011 at 2:42 am #349707

lerkan
@lerkan

Here’s the source code for a doodle jump game: https://github.com/haqu/tweejump

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.