Is there a way to call the -(void)update:(CCTime)delta
method in objective-c? I know that (using sprite builder) I can create a scene and then have it be attached to a custom class so that when the scene is loaded through the CCBReader, the class's update method is automatically called.
I am now loading the scene through code without a custom class but would still like the update method to "start" (for lack of a better word.) Is there a way to do this?
Call scheduleUpdate
from, for example, onEnter
method.
[self scheduleUpdate];
However if you are using cocos2d-objc or cocos2d-spritebuilder version 3.0 or later, update:
methods is scheduled automatically.
https://github.com/cocos2d/cocos2d-objc/blob/v3.0/cocos2d/CCNode.m#L1190
-(CCTimer *) schedule:(SEL)selector interval:(CCTime)interval repeat: (NSUInteger) repeat delay:(CCTime) delay
{
NSAssert(selector != nil, @"Selector must be non-nil");
NSAssert(selector != @selector(update:) && selector != @selector(fixedUpdate:), @"The update: and fixedUpdate: methods are scheduled automatically.");