Responding to touch in other classes

I am building an iPhone application on top of the OpenGL template for iPhone. I was about to add user interaction to the application when I noticed that it would not respond to touches in several of my classes.

It is currently GameAppDelegatecalling my EAGLViewclass ' method startAnimation, which ultimately calls my ES1Rendererclass' method render, which then finally calls my method Scene render. At the moment I know that this is a mess, but in the end I will clean it.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)eventonly called and checked in my class EAGLView. I don’t know what I am missing in other classes (most importantly, my class Scene), which automatically checks if I have this method and its implementation.

+3
source share
1 answer

Judging only by the naming scheme, it Scenedoesn't seem to be UIView. The touch event method is called by touching UIView- in this case yours EAGLView. If you want the class to Scenehandle it, you can simply call the method directly:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [myScene touchesBegan:touches withEvent:event];
}
0
source

Source: https://habr.com/ru/post/1776607/


All Articles