将UIButton
添加到SKScene
的最佳方式是什么?将UIButton添加到SKScene
我意识到我可能无法将其添加为场景的子视图,那么替代方案是什么,以便我可以在场景的顶部有一个可点按的按钮?
将UIButton
添加到SKScene
的最佳方式是什么?将UIButton添加到SKScene
我意识到我可能无法将其添加为场景的子视图,那么替代方案是什么,以便我可以在场景的顶部有一个可点按的按钮?
/// create a uibutton in skscene (spritkit)
UIButton * startButton = [[UIButton alloc]initWithFrame:CGRectMake(100, 200, 60, 20)];
startButton.backgroundColor = [UIColor redColor];
[self.view addSubview:startButton];
/// if u want to connect it to a method or function ///
[startButton addTarget:self action:@selector(StartBtn) forControlEvents:UIControlEventTouchUpInside];
请参考这里的答案:http://stackoverflow.com/questions/19082202/spritekit-setting-up-buttons-in-skscene – ZeMoon
UIKit的视图(只能)添加到SKView,不现场或其他节点 – LearnCocos2D