【发布时间】:2014-04-23 00:13:28
【问题描述】:
与 Game Center 合作,我决定创建一个 UIButton,我称之为排行榜。问题是,在 myScene 上,当 Start Button(一个 sprite-kit 节点)被触摸时,我需要将排行榜移出屏幕但不能这样做,因为它发生在 myScene 而不是 ViewController 上。
-(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 在屏幕上仍然可见,从而扰乱了游戏。非常感谢任何帮助。
【问题讨论】:
标签: ios sprite-kit viewcontroller