我正在 iPhone 的 OpenGL 模板之上构建一个 iPhone 应用程序。当我注意到它不会响应我的一些类(class)中的触摸时,我正要向应用程序添加用户交互。
目前,GameAppDelegate
调用我的 EAGLView
类的 startAnimation
方法,该方法最终调用我的 ES1Renderer
类' render
方法,然后最终调用我的 Scene
render
方法。我知道现在有点乱,但我最终会把它清理干净。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
仅在我的 EAGLView
类中调用和检查。我不知道其他类(最重要的是我的 Scene 类)中缺少什么,这些类会自动检查我是否有该方法并实现它。
最佳答案
仅从命名方案来看,听起来 Scene
并不是 UIView
。无论 UIView
被触摸,都会调用触摸事件方法 - 在本例中为您的 EAGLView
。如果您希望 Scene
类来处理它,您可以直接调用该方法:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[myScene touchesBegan:touches withEvent:event];
}
关于iphone - 在其他类(class)中对触摸使用react,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4263271/