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?
In my C++/Cocos2d-x code I have some custom Cocos2d actions; in my case, classes
Share
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
CCActionManagerclass. So, by checking that class, you can see:As you can see,
removeActionis called when theisDone()is true. Not surprisingly, theisDone()method inCCActionInstantalways returns true, hence always gets removed after excuting once :).