在SKScene gamescene中,我分配了场景,但它有No visible @interface with 'SKScene' declares the selector alloc.
的错误消息
我认为这意味着我不能在我的界面中声明它?更正plz。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
// if play button touched, start transition to next scene
if ([node.name isEqualToString:@"play"]) {
NSLog(@"play pressed");
SKScene *GameScene = [[GameScene alloc] initWithSize:self.size];
SKTransition *flip = [SKTransition flipVerticalWithDuration:1.0];
[self.view presentScene:GameScene transition:flip];
}
}
答案 0 :(得分:3)
看起来您正在尝试创建一个与该类同名的变量!
SKScene *GameScene = [[GameScene alloc] initWithSize:self.size];
这可能会让编译器感到困惑。将* GameScene的变量名称更改为其他名称,看看是否有效。