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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:10:09+00:00 2026-06-14T14:10:09+00:00

In my C++/Cocos2d-x code I have some custom Cocos2d actions; in my case, classes

  • 0

In my C++/Cocos2d-x code I have some custom Cocos2d actions; in my case, classes inheriting CCActionInterval or CCActionInstant. I notice a difference between Cocos2d-x version 1.0.1 and version 2.0 in how update methods of these classes are called . Before the upgrade, the update methods were always called at least once with time=1.0. From what I see now, in version 2.0, the update method of the instant actions is called only once with time=0. Is it always so? Can I assume that, in version 2.0, in classes inheriting CCActionInstant, the update method will be called only once and the time value will always be zero?

  • 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-14T14:10:11+00:00Added an answer on June 14, 2026 at 2:10 pm

    I’ll say this first, I don’t think you should be worrying about such implementation detail. When you subclass CCActionInstant, you can always assume that your subclass is an instant action. If the implementation details changed in the future, they’ll probably be made to make the class even better, and your subclass should perform better.

    With that being said, you might have your reason to worry about this implementation detail, so, here is an extended answer.

    You can assume it is always called at time 0 as long as you don’t update your library. Cocos2d-x is very dynamic, and changing according to the cocos2d-iphone version, so changes are bound to happen.


    In cocos2d v2.0, all actions are managed by the CCActionManager class. So, by checking that class, you can see:

    // main loop
    void CCActionManager::update(float dt)
    {
    ...
        if (m_pCurrentTarget->currentAction->isDone())
        {
            m_pCurrentTarget->currentAction->stop();
    
            CCAction *pAction = m_pCurrentTarget->currentAction;
            // Make currentAction nil to prevent removeAction from salvaging it.
            m_pCurrentTarget->currentAction = NULL;
            removeAction(pAction);
        }
    }
    

    As you can see, removeAction is called when the isDone() is true. Not surprisingly, the isDone() method in CCActionInstant always returns true, hence always gets removed after excuting once :).

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

Sidebar

Related Questions

In X code, I have added 3 groups named * Classes * COCOS2d *
Scenario: I have run and compiled an existing c++ code of cocos2d-x on android
I have made a code for scrolling a background in Cocos2d to create an
I have written my code in following way in cocos2d. id actionTo = [CCFadeOut
I am doing some r &d in cocos2d.I have one backgroundLayer and add one
I am using cocos2d and have the following code which moves my layer based
Let us say we have some code that looks like below: @interface SomeClass :
I'm just learning Cocos2d and Objective-C, and I have some problems with touch detection.
In the default cocos2d 1.0 beta template, AppDelegate.m has some code: // AppDelegate.m //
I have cocos2d project with custom CCSprite subclass: MyCustomSprite.h: #import cocos2d.h @interface MyCustomSprite :

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.