GLSurfaceView 纹理矩形作为按钮点击
我只想问一个与 GLSurfaceView 和其上绘制的对象相关的简单问题。我正在绘制一个矩形并将纹理绑定到它。效果很好。然后,我正在绘制的纹理矩形位于 GLSurfaceView 上。我正在绘制一个类似“按钮”的对象,我应该知道用户是否单击了该按钮。
我想像这样:如果用户点击屏幕并且点击的 .y 位于绘制对象的矩形中(在我的例子中是按钮),我需要执行另一个操作(即更改另一个视图等)。 ..)。我的想法正确吗?
现在的问题是:如何处理用户交互?如何获取映射在 GLSurfaceView 上的绘制对象(按钮)的 Rect(即 Rect(120, 80)),以便我可以检查用户是否单击了按钮?或者还有其他方法。
我还对以下内容感兴趣: 我想让我的应用程序完全基于 opengl es。我不会使用 Android 中的按钮视图。我正在处理大纹理,我认为 OpenGL ES 是更好的方法,因为通过平移、旋转和缩放的动画更容易处理。我说得对吗?
谢谢
I just want to ask a simple question related the GLSurfaceView and drawn objects on it. I am drawing a rect and bind a texture to it. It works great. Then, the textured rect I am drawing is on a GLSurfaceView. I am drawing a "button"-like object for which I should know whether the user clicked on the button or not.
I imagined that like this: if the user taps the screen and the .y of the tap are in the rect of the drawn object (in my case the button), I need another operation to be performed (i.e. change another view or so...). Is my idea correct?
Now the question: How do I handle user interactions? And how can I get the Rect of the drawn object (button) maped on the GLSurfaceView (i.e. Rect(120, 80)) so that I can then check whether the user clicked the button or not? Or there is some other approach.
Also I am interested in the following:
I have in mind to make my application full opengl es based. I won't use Button views from Android. I am working with big textures and I think OpenGL ES is the better way to do it since animations via translations and rotations and scaling are much easier to handle. Am I right?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 onTouchEvent 获取用户触摸的 x 和 y 点。
You can use onTouchEvent to get the x and y points where user touches.