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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:18:35+00:00 2026-06-17T17:18:35+00:00

Currently, I have a game where an object determines a point to go to.

  • 0

Currently, I have a game where an object determines a point to go to. It then calculates a path to that point and constructs one long CCMoveTo animation to get to that point. With this method, the animation seems very smooth and continuous.

I am now trying to break this one long CCMoveTo to multiple CCMoveTo leveraging the update method that gets called periodically. I want to do this because at each node of the path that the objects passes through, there might be a distraction and I want my object to be able to act on that. So this is what I am doing:

- (void) update: (ccTime) dt
{
    if(![self isWalking]){
        CGPoint nextNode = [_path objectAtIndex:(_currentPathIndex%[_path count])];
        _currentPathIndex++;
        NSMutableArray *actions = [[NSMutableArray alloc] init];
        [actions addObject:[CCCallBlockO actionWithBlock:^void(id obj) {
            [(Monkey *) obj setIsWalking:NO];
        }                                         object:self]];
        [self moveTo: nextNode withCallbacks: actions];
    }
}

Note: that I set isWalking to NO as a callback when the object has completely reached the destination node. This will let it calculate the next node to go to and construct that animation. Without this, the object would try to runAction in the middle of an ongoing CCMoveTo action. The problem with this method is that the movement does not seem smooth and continuous anymore. There seems to be a lag at the end of each CCMoveTo animation

Anybody has any clue on how to fix this?

  • 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-17T17:18:37+00:00Added an answer on June 17, 2026 at 5:18 pm

    That’s a side effect of cocos2d’s CCAction system respectively the CCScheduler.

    There will always be a 1-frame delay because when an action stops, it won’t do any work in the current frame: it made the last position update in the previous frame, and in the current frame it does no longer exist as a running action.

    If you now run another move action in a scheduled method, that action won’t begin updating until the next frame because it will schedule itself to receive updates. And updates that are scheduled while cocos2d’s CCScheduler performs updates will not be run until the next frame, due to the fact that you can’t modify an array during enumeration.

    My advise is always to avoid using CCMove* actions for gameplay purposes, and instead manually update position of game objects. It’s easy enough to do, and if you need a code example, look inside the CCMoveTo class.

    A workaround would be to extend the distance of the CCMoveTo and replace the action shortly before it completes. Though that’ll be a hack and may actually be harder to implement correctly than manual position updates.

    PS: That’s an issue I have addressed in the action model of KoboldTouch. It implements its own action system, with more lightweight and reusable actions.

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

Sidebar

Related Questions

I currently have a small text game I've written in Java that utilizes System.out.print();
I have a game that currently runs under Windows and Mac OS X and
I currently have a game that takes in large images, easily bigger than 1MB,
I'm currently developing a simple 2D game for Android. I have a stationary object
i have developed a game that is currently running on iphone/ipad/ipod touch without any
I am writing a somewhat complex game engine in Android. Currently I have a
I'm currently working on a game and I wish to have a main menu
i am currently working on a facebook game and i have a problem concerning
I'm currently developing a doodle-jump style game in Cocos2d for iPhone and have a
Currently have a drop down menu that is activated on a hover (from display:none

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.