我正在为I-pad touch做一个小游戏,作为游戏编程模块的一部分.我只是根据触摸的按钮处理菜单简单的场景变化.它似乎工作得很好,除了一个特定的场景机会.
尝试触摸导致我进入选项菜单的按钮时出现以下错误:
- [MainMenu的goToOptions:]:无法识别的选择发送到实例0xae2a1d0 *终止应用程序由于未捕获的异常'NSInvalidArgumentException',原因: ' - [MainMenu的goToOptions:]:无法识别的选择发送到实例0xae2a1d0'
而且,这是我的代码中与崩溃相关的部分,以及导致场景更改的两个函数:
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for( UITouch *touch in touches ) {
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
CCActionInterval *actionInterval = [CCActionInterval actionWithDuration:0.1];
if (CGRectContainsPoint([self.startButton boundingBox], location)) {
[self.startButton setTexture:[[CCTextureCache sharedTextureCache] addImage:@"BeginButton.png"]];
id actionCallFunc = [CCCallFunc actionWithTarget:self selector:@selector(goToInstructions:)];
[self.background runAction: [CCSequence actions: actionInterval, actionCallFunc, nil]];
}
else if (CGRectContainsPoint([self.optionsButton boundingBox], location)) {
[self.optionsButton setTexture:[[CCTextureCache sharedTextureCache] addImage:@"OptionsButton.png"]];
id actionCallFunc = [CCCallFunc actionWithTarget:self selector:@selector(goToOptions:)];
[self.background runAction: [CCSequence actions: actionInterval, actionCallFunc, nil]];
}
}
}
-(void) goToInstructions:(id) sender
{
[[CCDirector sharedDirector] replaceScene: [CCTransitionSlideInL transitionWithDuration:2 scene:[InstructionsMenu node]]];
}
-(void) goToOpctions:(id) sender
{
[[CCDirector sharedDirector] replaceScene: [CCTransitionFlipY transitionWithDuration:2 scene:[OptionsMenu node]]];
}
@end
Run Code Online (Sandbox Code Playgroud)
知道崩溃的原因是什么以及我如何解决它?
你在方法名称中输入了一个拼写错误,请尝试:
-(void) goToOptions:(id) sender { // <--- TYPO here
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
130 次 |
| 最近记录: |