gpt4 book ai didi

ios - SKScene分配错误

转载 作者:行者123 更新时间:2023-12-01 19:01:36 25 4
gpt4 key购买 nike

在SKScene游戏场景中,我分配了场景,但它带有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];
}
}

最佳答案

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

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

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

关于ios - SKScene分配错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22468161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com