基本上现在我得到了TitleScene,我的游戏名称在哪里,当点击屏幕上的任何地方时它会跳到GameScene,它看起来像这样:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
SKScene *scene = [GameScene sceneWithSize:self.size];
SKTransition *transition = [SKTransition pushWithDirection:SKTransitionDirectionUp duration:1.0f];
[self.view presentScene:scene transition:transition];
}
我的问题如何将此方法更改为按钮?
答案 0 :(得分:1)
也许给你的精灵命名为“按钮”,这样你就知道你正在触摸哪一个
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */
for (UITouch *touch in touches) {
CGPoint location = [touch locationInNode:self];
SKNode *touchedNode = [self nodeAtPoint:location];
if (touchedNode && [touchedNode.name isEqual:@"button"]) {
// your code here
}
}
}