将文本字段添加到SKScene [英] Adding textfield to SKScene

查看:129
本文介绍了将文本字段添加到SKScene的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Sprite Kit创建游戏,并且我想添加一个文本字段供玩家输入他们的名字.

I am creating a game using Sprite Kit, and I want to add a textfield for players to enter their name.

如何使用Sprite Kit创建文本字段?我将创建一个播放器对象(已经设置好),并使用输入的名称和默认分数0来混合UITextfields和Sprite Kit节点,这是否是错误的做法,甚至可能? >

How can I create a textfield using Sprite Kit? I'm going to create a player object (which I already have set up) and use the name they enter and a default score of 0. Is it bad practice, or even possible, to mix UITextfields and Sprite Kit nodes?

推荐答案

类似这样的东西

UILabel *nameField = [[UILabel alloc] initWithFrame:CGRectMake(200, 200, 300, 100)];
[self.view addSubview:nameField];

但是我建议像其他任何iOS应用一样设置布局.

But I suggest, setting up your layout as you would for any other iOS app.

在我的选择中混合2比它的价值更麻烦.这样您就可以拥有一个简单的场景,并显示一个模态视图,您可以在IB中进行设置并存储人员姓名.

Mixing the 2 in my option is more trouble than what its worth. So you can have a simple scene, the displays a modal view, which you can set up in IB and store the persons name.

这篇关于将文本字段添加到SKScene的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆