Cocos2d只安排一次

Dan*_*ani 8 cocos2d-iphone

如何只制作一次cocos2d计划选择器?现在我能做的最好的事情是:

[self schedule:@selector(eventHappend:) interval:2];
Run Code Online (Sandbox Code Playgroud)

eventHappend:

- (void)eventHappend: (ccTime) dt
{
    [self unschedule:@selector(eventHappend:)];
    // Do stuff
}
Run Code Online (Sandbox Code Playgroud)

但这似乎是一种解决方法......有一种方法只能安排一次吗?

Fra*_*ham 9

您可以在节点上运行一系列操作,CCDelay后跟一个调用方法的CCCallFunc.

像这样...

[self runAction:[CCSequence actions:[CCDelayTime actionWithDuration:2], 
                                    [CCCallFunc actionWithTarget:self selector:@selector(eventHappened)],
                                    nil]];
Run Code Online (Sandbox Code Playgroud)