Animation 如何停止所有动画并在屏幕上显示一系列精灵?

Animation 如何停止所有动画并在屏幕上显示一系列精灵?,animation,cocos2d-iphone,Animation,Cocos2d Iphone,我正在为我的cocos2d(-iphonev2.0)platformer/running游戏实施教程模式-当用户处于教程模式时,我需要暂停游戏并提供说明。在游戏中,我需要停止所有动画,并按顺序向用户提供一些输入,相互覆盖(比如间隔1秒) 在我的游戏层中,在需要的时候,我调用[[CCDirector sharedDirector]stopAnimation],停止所有动画。现在,我想连续呼叫两次,间隔1秒。我没有收到任何更新调用,因为动画已停止。因此,我尝试使用NSTimer,如下所示: -(vo

我正在为我的cocos2d(-iphonev2.0)platformer/running游戏实施教程模式-当用户处于教程模式时,我需要暂停游戏并提供说明。在游戏中,我需要停止所有动画,并按顺序向用户提供一些输入,相互覆盖(比如间隔1秒)

在我的游戏层中,在需要的时候,我调用
[[CCDirector sharedDirector]stopAnimation]
,停止所有动画。现在,我想连续呼叫两次,间隔1秒。我没有收到任何更新调用,因为动画已停止。因此,我尝试使用NSTimer,如下所示:

-(void)update
{
  //...
  [[CCDirector sharedDirector]stopAnimation];
  //...
  [self showFirstTutorialInstruction];
  NSTimer *timer = [[NSTimer scheduledTimerWithTimeInterval:1.0
  target:self
  selector:@selector(showNextTutorialInstruction)
  userInfo:nil
  repeats:NO]retain];
  //...
}

-(void)ccTouchBegan(...)
{
  //...
  [CCDirector sharedDirector]startAnimation];
  //...
}

现在动画停止,计时器函数被调用,但是选择器中的第二条指令直到我重新启动动画后才会显示在显示区域中。如何使
shownextutorialinstruction
中的第二条指令在调用后立即显示?我已尝试强制访问该层,但不起作用。

如何编写更新方法来提供您的动作/动画?可以使用暂停来代替停止动画。例如,我在一个测试项目中尝试了这一点

-(void)startPause {
    if(!isPaused) {
        isPaused = YES;
        [[CCDirector sharedDirector] pause];
        [self performSelector:@selector(addLabel) withObject:nil afterDelay:2.0];
    } else {
        isPaused = NO;
        [self removeChild:addLabel cleanup:YES];
        [[CCDirector sharedDirector] resume];
    }
}

-(void)addLabel {
    addLabel = [CCLabelTTF labelWithString:@"TEST" fontName:@"Arial" fontSize:20];
    [self addChild:addLabel];
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    addLabel.position = ccp(winSize.width/2, winSize.height/2);
}
[[CCDirector sharedDirector]暂停];在cocos2d文档中概述为“暂停运行场景。运行场景将被绘制,但所有计划的计时器将在暂停时暂停,绘制速率将为4 FPS以减少CPU消耗”

我使用的isPaused是一个BOOL,在我最开始的更新方法中,我有一行

if (isPaused) { return; }
但现在回想起来,你根本不需要这些。由于我的PerformSelect中的计时器是在控制器暂停后添加的,因此它将按计划运行。这将使您能够获得添加所需内容的预期结果