adding uitextfield or (textentry box with keyboard) in sprite kit

只愿长相守 提交于 2019-12-24 11:36:45

问题


I am recently working on sprite kit to create a simple game where user input name as identity and moves forward to play game and has option to edit name or replace name. Which is best option to use uitextfield: in skscene or viewcontroller? Or any other solutions?

I had tried with uitextfield adding in skscene but got memory issue (since i called scene from viewwilllayoutSubview

   override func viewWillLayoutSubviews() {
    let skView = self.view as! SKView
    skView.ignoresSiblingOrder = true
    let scene =
        NameEntryScene(size:CGSize(width: 1024, height: 718))
    scene.scaleMode = .aspectFill
    skView.presentScene(scene)

}

which I followed stackoverflow others answer to add uitextfield in gamesence at didMove(to view: SKView).

Also created uitextfield in viewcontroller and pass its instance all over the gamesence with action of isHidden true and false to remove memory issue, which worked but I can't work like this if i have many uitextfield's at various postions.

Any suggestion and help is very much appreciated. Thanks in advance.

来源:https://stackoverflow.com/questions/40463677/adding-uitextfield-or-textentry-box-with-keyboard-in-sprite-kit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!