【问题标题】:Error for SKScene allocSKScene 分配错误
【发布时间】:2014-03-18 00:28:39
【问题描述】:

在 SKScene 游戏场景中,我分配了场景,但它有一个带有 No visible @interface with 'SKScene' declares the selector alloc. 的错误消息

我认为这意味着我没有在我的界面中声明它??请指正。

     -(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];
   }
}

【问题讨论】:

    标签: ios iphone sprite-kit skscene


    【解决方案1】:

    看起来您正在尝试创建一个与类同名的变量!

    SKScene *GameScene = [[GameScene alloc] initWithSize:self.size];
    

    这可能会使编译器感到困惑。将 *GameScene 的变量名称更改为其他名称,看看是否可行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-27
      • 1970-01-01
      • 2014-04-28
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 2022-07-27
      • 1970-01-01
      相关资源
      最近更新 更多