处理游戏不同部分的 UITouches open gl ES iphone

发布于 2024-08-06 20:31:45 字数 235 浏览 4 评论 0原文

这里有一个简化的例子:

我有一个用 opengl es 编写的游戏。该游戏有两个不同的屏幕,根据用户的触摸输入执行完全不同的操作。

从视图中抽象出 uitouch 事件的最佳方法是什么?

我想在完美的世界中,触摸事件将由我的游戏循环处理,但由于视图处理我的触摸事件,我不知道如何让游戏循环处理它们。

多个 EAGLView?

处理游戏中两个不同屏幕之间的触摸的最佳方法是什么?

A simplified example here:

I have a game that I am writing in opengl es. The game has two different screens that do completely different things based on the user's touch input.

What is the best way to abstract out the uitouch events from the view?

I imagine that in a perfect world the touch events would be handled by my game loop, but because the view handles my touch events I don't know how to make the game loop handle them.

Multiple EAGLViews?

What is the best way to handle touches between two different screens in your game?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

想挽留 2024-08-13 20:31:45

我不明白为什么你无法处理游戏循环中的触摸。只需将触摸事件记录到视图触摸处理程序中的数据结构(列表或其他内容)即可。然后在游戏循环中仅处理已记录到数据结构中的事件。只需确保一次只有一个线程更改数据结构即可。

如果游戏循环中更简化的数据就足够了,您甚至不需要记录事件。在简单的情况下,您可以只更新触摸处理程序中的 touchX、touchY 和 touchState(无、开始、移动、结束)等变量,并在游戏循环中读取这些变量。在这种情况下,您可能希望确保游戏循环能够以合理的方式对开始和结束事件做出反应。 IE。开始和结束状态应始终持续恰好一个刻度。

I don't see why you couldn't handle touches in your game loop. Just record the touch events to a data structure (a list or something) in the views touch handlers. Then in the game loop just process what ever events have been recorded to the data structure. Just make sure that only one thread changes the data structure at a time.

You don't even need to record the events if more simplified data is enough in the game loop. In simple cases you could just update variables like touchX, touchY and touchState (none, began, moved, ended) in the touch handlers and read these variables in the game loop. In this case you may want to make sure that the game loop can react to to both began and ended events in a sensible way. Ie. began and ended states should always last for exactly one tick.

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