Cocos2d iphone cocos2d启动/停止运行场景

Cocos2d iphone cocos2d启动/停止运行场景,cocos2d-iphone,scene,Cocos2d Iphone,Scene,我试着加载一个场景。这在第一次运行正常,但当我再次尝试重新加载时,会在放置动画的位置出现一个白色正方形 这是启动和停止场景的代码。我错过了什么 谢谢 -(void)runScene:(OTAnimationCC2d *)animation { scene = [CCScene node]; [scene addChild:animation]; if ([[[CCDirector sharedDirector] runningScene] isRunning])

我试着加载一个场景。这在第一次运行正常,但当我再次尝试重新加载时,会在放置动画的位置出现一个白色正方形

这是启动和停止场景的代码。我错过了什么

谢谢

-(void)runScene:(OTAnimationCC2d *)animation
{
    scene = [CCScene node];

    [scene addChild:animation];

    if ([[[CCDirector sharedDirector] runningScene] isRunning])
    {
        [[CCDirector sharedDirector] replaceScene:scene];
    }
    else
    {
        [[CCDirector sharedDirector] runWithScene:scene];
    }

}
-(void)stopScene
{
    [[[CCDirector sharedDirector] runningScene] stopAllActions];
    [[[CCDirector sharedDirector] runningScene] removeAllChildrenWithCleanup:YES];
    [[CCDirector sharedDirector] pushScene:scene];

}

为什么不在
停止场景的末尾调用
[self runScene]
,而不是
[[CCDirector sharedDirector]pushScene:scene]
?听起来像是希望场景重新加载,当调用
replaceSecene
时,
runScene
已经这样做了


无论哪种方式,您都应该创建一个新的场景节点并使用
replaceSecene
(这是在
runScene
中完成的,这就是为什么我建议只调用它)。

需要更多信息。。。这些方法是如何调用的,以及为什么在stopScene结束时将场景推回到自身上。