Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6828541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:23:43+00:00 2026-05-26T22:23:43+00:00

I am really looking to try to have gravity in my game. I know

  • 0

I am really looking to try to have gravity in my game. I know everyone says use Box2D, but in my case I can’t. I need to use Cocos2D for the gravity.

I know Cocos2D does not have any gravity API built in so I need to do something manually. The thing is there is like no tutorials or examples anywhere on the web that show this.

Can anyone show me what they have done or can some explain step by step on how to apply a non-constant gravity (One that gets slightly stronger while falling).

I think this will help a lot of people that are facing the same issue that I am having!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:23:44+00:00Added an answer on May 26, 2026 at 10:23 pm

    Gravity is nothing but a constant velocity applied to the body for every physics step. Have a look at this exemplary update method:

    -(void) update:(ccTime)delta
    {
       // use a gravity velocity that "feels good" for your app
       const CGPoint gravity = CGPointMake(0, -0.2);
    
       // update sprite position after applying downward gravity velocity
       CGPoint pos = sprite.position;
       pos.y += gravity.y;
       sprite.position = pos;
    }
    

    Every frame the sprite y position will be decreased. That’s the simple approach. For a more realistic effect you will want to have a velocity vector for each moving object, and apply gravity to the velocity (which is also a CGPoint).

    -(void) update:(ccTime)delta
    {
       // use a gravity velocity that "feels good" for your app
       const CGPoint gravity = CGPointMake(0, -0.2);
    
       // update velocity with gravitational influence
       velocity.y += gravity.y;
    
       // update sprite position with velocity
       CGPoint pos = sprite.position;
       pos.y += velocity.y;
       sprite.position = pos;
    }
    

    This has the effect that velocity, over time, increases in the downward y direction. This will have the object accelerate faster and faster downwards, the longer it is “falling”.

    Yet by modifying velocity you can still change the general direction of the object. For instance to make the character jump you could set velocity.y = 2.0 and it would move upwards and come back down again due to the effect of gravity applied over time.

    This is still a simplified approach but very common in games that don’t use a “real” physics engine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am really stumped because I have basic ideas but I am looking
Its not really a subtraction I'm looking for. And I know its not a
I'm looking for a scoring algorithm but I really don't find what I'm looking
I have a really frustrating error that I've spent hours looking at and cannot
this is probably a really stupid problem, but i've been looking at it for
I know that this is not the first thread on this topic,but I have
I have a page that shows images and the images are really looking messed
I have a strange problem and really dont know where to start debug. I
I have been looking for an answer for this, but none seem to actually
I have written a simple game and am looking to integrate GameCenter Achievements with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.