Objective c 未调用另一个场景中的方法
显示“thePlay”,但不显示红色背景。它仍然是黑色的。有人能告诉我该做什么吗。 更多说明:所有场景和quickMenu类都是相互导入的 此方法使用SKNode的quickMenu类子类中的按钮执行从此场景转换Objective c 未调用另一个场景中的方法,objective-c,sprite-kit,background-color,transitions,skscene,Objective C,Sprite Kit,Background Color,Transitions,Skscene,显示“thePlay”,但不显示红色背景。它仍然是黑色的。有人能告诉我该做什么吗。 更多说明:所有场景和quickMenu类都是相互导入的 此方法使用SKNode的quickMenu类子类中的按钮执行从此场景转换 -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches){ if (self.gameEnded && qu
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches){
if (self.gameEnded && quickMenu.touchable) {
SKNode *theNode = [quickMenu nodeAtPoint:[touch locationInNode:quickMenu]];
if ([theNode.name isEqualToString:@"theMenu"]){
SKScene *thePlay = [[SKScene alloc] initWithSize:self.size];
SKTransition *doors = [SKTransition doorsOpenHorizontalWithDuration:1.0];
[self.view presentScene:thePlay transition:doors];
}
}
}
}
这是另一个场景Play场景中的第一种方法
-(void)didMoveToView:(SKView *)view
{
self.backgroundColor = [SKColor redColor];
NSLog(@"this method called");
}
我尝试了init方法,也没有显示红色背景,如下所示
-(id)initWithSize:(CGSize)size
{
if (self = [super initWithSize:size]) {
self.backgroundColor = [SKColor redColor];
NSLog(@"init method called");
}
我遗漏了什么吗?您正在创建并演示一个SKScene,而不是thePlay scene。转换后无法调用init方法。