1
使用Game Center我決定創建一個我稱之爲排行榜的UIButton。問題是,在myScene上,當啓動按鈕(一個精靈套件節點)被觸動時,我需要將排行榜從屏幕上移開,但不能這樣做,因爲它出現在myScene而不是ViewController上。從Sprite-Kit場景中移動一個UIButton
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if ([node.name isEqualToString:@"Start"]) {
self.Start.position = CGPointMake(-100, -100);
self.Instructions.position = CGPointMake(-100, -100);
//Leaderboards need to be moved off screen now.
}
}
在ViewController中,我將使用下面的代碼將排行榜按鈕移出屏幕,但不能在myScene上使用它。
Leaderboards.center = CGPointMake(-100, -100);
目前UIButton在屏幕上仍然可見,破壞遊戲。任何幫助是極大的讚賞。