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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:55:31+00:00 2026-05-14T01:55:31+00:00

I’m making a little iphone game, and I would get some clues. Let’s imagine:

  • 0

I’m making a little iphone game, and I would get some clues.
Let’s imagine:

Two background sprites moving pretty fast from right to left, and moving up and down with accelerometer.

I guess I can’t use animations here, cause the movement of the background is recalculated at each frame.
So I use a schedule with an interval of 0.025s and move my sprites at each clock with a :

sprite.position = ccp(x, y);

So here is my problem: the result is laggy, with only these two sprites.

I tried both declaring sprites in the header, and getting them with CCNodes and Tags. It’s quite the same.

So if someone can give me a hint on what is the best way to do that, that would be so nice. I wonder if the problem can’t be the fact that sprites are moving very fast, but i’m not sure.

Anyway, thanks for your time.

J.

  • 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-14T01:55:31+00:00Added an answer on May 14, 2026 at 1:55 am

    0.025 equals 40 fps, that could be a bit steep depending on the rest of your game loop. It’s good to think about the relationship between framerate and percieved speed. When you increase framerate, you make the movement smoother, but only as long as you know how to calculate the motion. If you move the objects with by a fixed distance with each tick of the time, they will stutter, because the timer is not precise. (Think about it: 40 fps means 25 ms per frame. When the timer gets off by five milliseconds – not very much, is it? –, you change the frame time by 20 percent. It is not unusual for the time events to get off by 10–20 ms.)

    This means that you have to calculate the real time delta from the last frame and move the objects according to it. A bit like this:

    const int kDesiredModelFramerate = 50; // fps
    const double kDesiredFrameTime = 1.0/kDesiredModelFramerate;
    
    double now = CFAbsoluteTimeGetCurrent();
    double delta = now - lastFrameTime;
    double correction = delta/kDesiredFrameTime;
    [object setX:object.x + step*correction];
    

    This looks complicated, but isn’t. When it took 40 ms from the last frame, you know you are one frame “late”, since to keep the desired framerate of 50 fps you’d like to keep each frame under 20 ms. Therefore the correction will be 0.04/0.02 = 2 and the usual movement step will get multiplied by 2 to make up for the lag. Now you can change the framerate as you wish – the percieved speed of the movement will stay the same, only the smoothness of the motion will change.

    <voice class="Simon Peyton Jones">Does that make sense?</voice>

    There is a great article about game loops where you can read about this in more detail. It’s a must read for game programmer. The exact way to realize all this in Cocos2D can vary, but the point remains the same. Getting this issue should help you get things moving smooth and fast.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.