iphone - 在其他类(class)中对触摸使用react

标签 iphone

我正在 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/

相关文章:

iphone - 使用 JSON 查询模拟 MVC 架构

iphone - Windows 上的 iOS 开发

iphone - iOS 上是否支持 SMB/samba?

ios - 为我的应用创建夜间主题

iphone - 应用程序不会在 iOS6 上开始使用 testflight

iphone - SimpleTabBarController 泄漏内存

ios - NSMutableArray 按标题排序

ios - iphone 5S 导出视频时慢动作没有了

iphone - SKPaymentTransaction.originalTransaction.transactionReceipt 为零

iphone - 在 View Controller 之间传递数组?