XCode程序:用户可以通过触摸与之交互的文本框
我是Xcode和Swift的新手。
我想为视频游戏创建一个文本框,该视频游戏充当游戏与用户之间的对话。例如,我希望文本框说(字符名称)行走了10个步伐或“二手检测到60'之内的邪恶'兽人。”
我还希望用户能够向用户施加压力触摸此聊天短信,该聊天文本是从计算机发送的然后采取一系列动作。例如,如果圣骑士发现邪恶,那么下一步的行动可能是躲藏或准备战斗。关于如何设置的任何想法?我一直在尝试在main.storyboard上创建它。我只能通过ViewController或其中一个代表来实现这一目标吗?
I am new to Xcode and Swift.
I want to create a text box for a video game that acts as the dialogue between the game and the user. for example I want the text box to say (character name) walked 10 paces or "Used 'detect evil' orc within 60'. "
I also want the ability for the user to pressure touch this chat text message which is sent from the computer and then do a series of actions. For example if a paladin detects evil maybe the next course of action would be to hide or prepare to fight. Any ideas on how to set this up? I have been trying to create this on Main.storyboard. Can I only achieve this through the ViewController or one of the delegates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您只能通过编码来实现此目标(当然,将故事板用作您的盟友!),
如果您想拥有一个“可单击”的文本框,首先想到的只是一个按钮,没有背景颜色,看起来就像文字。
然后,您需要在ViewController的内部创建一个方法,理想情况下是这样的:
并通过在故事板上设置
TouchupinSide
方法将按钮连接到此功能。First of all, you can only achieve this by coding (by using Storyboards as your ally of course!)
If you want to have a text box that is "clickable", what first comes to mind is just a button, that have no background color, so it looks just like text.
Then you need to create a method inside of your ViewController, ideally something like:
And connect your button to this function by setting up a
touchUpInside
method in the Storyboard.