將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