XCode程序:用户可以通过触摸与之交互的文本框

发布于 2025-01-22 09:23:16 字数 269 浏览 2 评论 0原文

我是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦冥 2025-01-29 09:23:16

首先,您只能通过编码来实现此目标(当然,将故事板用作您的盟友!),

如果您想拥有一个“可单击”的文本框,首先想到的只是一个按钮,没有背景颜色,看起来就像文字。

然后,您需要在ViewController的内部创建一个方法,理想情况下是这样的:

@IBAction func dialogBoxTapped(_ sender: Any?) {
// your code goes here
}

并通过在故事板上设置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:

@IBAction func dialogBoxTapped(_ sender: Any?) {
// your code goes here
}

And connect your button to this function by setting up a touchUpInside method in the Storyboard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文