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 8120213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:04:23+00:00 2026-06-06T05:04:23+00:00

Could you please help me out to find the correct deceleration rate for the

  • 0

Could you please help me out to find the correct deceleration rate for the following scenario:
There’s a point A where car has to stop at. Let’s say the car is 200 pixels away from A and it’s travelling with velocity of 50. Now how can I achieve the correct deceleration so that the car kills down the speed gradually and finally stops at point A? In real world it’s quite easy but in computer world we have to take into account the fact that the car does not move in fact it’s just the screen redrawing it each time at a newer position. Just to mention there’s a schedule that fires the method that takes the car forward with the given velocity. So I think the schedule interval has also to be taken into account while calculating.
I don’t think language, device or platform matters but just in case I’m doing this in iPhone cocos2d

  • 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-06-06T05:04:25+00:00Added an answer on June 6, 2026 at 5:04 am

    Don’t worry, you don’t need a special kind of math here, you can use your “real world math” just fine. The problem with the scheduler and the framerate also isn’t a real one, but related to framerate dependend movement. Assuming that you have this function to move your object (half pseudo code):

    - (void)move
    {
        if(velocity.x < 5)
            return;
    
        car.x += velocity.x;
        velocity.x -= 5;
    }
    

    This code depends on the framerate, for example, if you render with 30 FPS and start with an velocity.x of 150, it will take exactly a second for the object to decelerate to 0. However, if you run the same method at an FPS of 60, it will take only half a second for the object to decelerate to 0.

    So what you really want is a way to move your car independent of the framerate, so that it moves in one second n points no matter what framerate you run your code. And the way to achieve this is by using the time that the frame will use to render, and multiply this delta time with your movement. And because you can’t predicate how long the frame will take to render before or while you are rendering it, you usually use the delta time of the previous frame. And then you end up with code looking like this:

    - (void)move
    {
        if(velocity.x < 5 * delta)
            return;
    
        car.x += velocity.x * delta;
        velocity.x -= 5 * delta;
    }
    

    (If you actually use this, you will see that your movement suddenly became A LOT slower because previously you moved 5 points per frame and now you are moving with 5 points per second!)

    I’m not a Cocos 2D pro, but it appears (from a quick google search), that you get the delta time in a few methods (I can’t name them, the class references don’t seem to mention them, but if you somewhere have a method which gets a ccTime passed every frame, thats probably one of them)

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

Sidebar

Related Questions

Could you please help me find out the time complexity of the Fleury' algorithm
Could someone please help me find out why my attempt to bind Collection to
Could someone please help me figure out what is wrong with the following code
Could someone please help me out with this. I need to find the gml:pos
Ok so could anyone please help me out with the VB for auto entering
yes, this is a homework-type question but could you please help me out? In
I have one intresting requirement to achieve. could you please help? Please find the
Could guys please help me find what causes memory leak ? It drives me
Could you please help me with following problem? Very often I must do the
Could you please help me to get image upload working on a view 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.