我有以下代码(应该是正确的):
- (void) loadIntro:(ccTime)unused {
[[GameManager sharedGameManager] runWithSceneID:kIntroScene]; // fade to the intro screen
}
- (void) loadAppScreen {
CCSprite *commodoreScreenLoaded = [CCSprite spriteWithFile:@"CommodoreLoadedApp.png"];
useBackgroundImage(commodoreScreenLoaded);
[self addChild:commodoreScreenLoaded];
}
- (void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
// location = [[CCDirector sharedDirector] convertToGL:location];
CGRect mySurface = (CGRectMake(100, 100, 320, 480));
if (CGRectContainsPoint(mySurface, location)) {
//[[CCDirector sharedDirector] stopAnimation];
play(@"InsertGameCartridge.wav");
[self removeChild:commodoreScreen cleanup:YES];
[self loadAppScreen];
[self schedule:@selector(loadIntro:) interval:2.5f]; // <-- Right here!
}
但是当我运行它时,它会记录一个非常奇怪的错误:
2012-07-29 12:21:41.186 Apocanaut[7299:707] *** Assertion failure in -[CCTimer initWithTarget:selector:interval:repeat:delay:],/Users/chris/src/Apps/Games/Apocanaut/Apocanaut/libs/cocos2d/CCScheduler.m:111
2012-07-29 12:21:41.190 Apocanaut[7299:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Signature not found for selector - does it have the following form? -(void) name: (ccTime) dt'
编辑:
它似乎来自GameManager
类中的一个方法,我已经实现了一个名为runWithSceneID
:
- (void) runWithSceneID:(SceneTypes)sceneID {
SceneTypes oldScene = currentScene;
currentScene = sceneID;
id sceneToRun = nil;
switch (sceneID) {
case kMenuScene:
sceneToRun = [MenuScene node];
break;
case kCommodoreScene:
sceneToRun = [CommodoreScene node];
break;
case kIntroScene:
sceneToRun = [IntroScene node];
break;
default:
CCLOG(@"No scene ID to load");
return;
break;
}
if (sceneToRun == nil) {
currentScene = oldScene;
return;
}
if ([[CCDirector sharedDirector] runningScene] == nil) {
[[CCDirector sharedDirector] runWithScene:sceneToRun];
} else {
[[CCDirector sharedDirector] replaceScene:
[CCTransitionFade transitionWithDuration:kStandardTransitionDuration scene:sceneToRun]];
}
}