2016-02-05 39 views
1

基本上現在我TitleScene,那裏是我的比賽現名,並當輕敲屏幕上就跳轉到GameScene任何地方,它看起來是這樣的:如何在雪碧包一個按鈕的touchesBegan

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

我的問題如何將此方法更改爲按鈕?

回答

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 
     } 
    } 
}