Ios 如何在Sprite工具包中制作触摸按钮开始
基本上现在我得到了TitleScene,我的游戏的当前名称在哪里,当点击屏幕上的任何地方,它就会跳转到游戏场景,它看起来像这样:Ios 如何在Sprite工具包中制作触摸按钮开始,ios,objective-c,sprite-kit,skspritenode,skscene,Ios,Objective C,Sprite Kit,Skspritenode,Skscene,基本上现在我得到了TitleScene,我的游戏的当前名称在哪里,当点击屏幕上的任何地方,它就会跳转到游戏场景,它看起来像这样: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { SKScene *scene = [GameScene sceneWithSize:self.size]; SKTransition *transition = [SKTransition pushWithDirection:SKTr
- (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];
}
我的问题是如何将此方法更改为button 也许给你的精灵起个“按钮”的名字,这样你就知道你在触摸哪个按钮了
-(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
}
}
}