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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:33:14+00:00 2026-05-24T23:33:14+00:00

I’m running on 40 FPS on my iOS cocos2d app with 80 Box2d objects.

  • 0

I’m running on 40 FPS on my iOS cocos2d app with 80 Box2d objects. I’m using fixed timestep:

-(void) update: (ccTime) dt
{
if( gameState_ != kGameStatePaused ) {
world_->Step(dt, 6, 1 );

....
}

Why is that happening? 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-24T23:33:15+00:00Added an answer on May 24, 2026 at 11:33 pm

    This is a better fixed time step:

    //FIX TIME STEP
    ///////--->>>>>>>>>>>>>
    const float32 FIXED_TIMESTEP = 1.0f / 60.0f;
    
    // Minimum remaining time to avoid box2d unstability caused by very small delta times
    // if remaining time to simulate is smaller than this, the rest of time will be added to the last step,
    // instead of performing one more single step with only the small delta time.
    const float32 MINIMUM_TIMESTEP = 1.0f / 600.0f;  
    
    const int32 VELOCITY_ITERATIONS = 8;
    const int32 POSITION_ITERATIONS = 8;
    
    // maximum number of steps per tick to avoid spiral of death
    const int32 MAXIMUM_NUMBER_OF_STEPS = 25;
    ///////<<<<<<<<<<<<<<<<<<-------------------
    
    //FIX TIME STEP----------->>>>>>>>>>>>>>>>
    -(void)afterStep {
    
         // process collisions and result from callbacks called by the step
    }
    
    
    -(void)step:(ccTime)dt {
        float32 frameTime = dt;
        int stepsPerformed = 0;
        while ( (frameTime > 0.0) && (stepsPerformed < MAXIMUM_NUMBER_OF_STEPS) ){
            float32 deltaTime = std::min( frameTime, FIXED_TIMESTEP );
            frameTime -= deltaTime;
            if (frameTime < MINIMUM_TIMESTEP) {
                deltaTime += frameTime;
                frameTime = 0.0f;
            }
            world->Step(deltaTime,VELOCITY_ITERATIONS,POSITION_ITERATIONS);
            stepsPerformed++;
            [self afterStep]; // process collisions and result from callbacks called by the step
        }
        world->ClearForces ();
    }
    //FIX TIME STEP<<<<<<<<<<<<<<<<<------------------
    
    
    -(void) tick: (ccTime) dt
    {
        //It is recommended that a fixed time step is used with Box2D for stability
        //of the simulation, however, we are using a variable time step here.
        //You need to make an informed choice, the following URL is useful
        //http://gafferongames.com/game-physics/fix-your-timestep/
    
        // Instruct the world to perform a single step of simulation. It is
        // generally best to keep the time step and iterations fixed.
        //  world->Step(dt, velocityIterations, positionIterations);
        [self step:dt];
    
        //Iterate over the bodies in the physics world
        for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
        {
            if (b->GetUserData() != NULL) {
    
                CCSprite *myActor;
                myActor = (CCSprite*)b->GetUserData();
    
                myActor.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO);
                myActor.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle());
    
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.