add touch begin/end on iOS

This commit is contained in:
2017-05-08 00:26:34 +01:00
parent d1ce547abd
commit 2e8c0d0865

View File

@@ -15,15 +15,19 @@
} }
@property (strong, nonatomic) EAGLContext *context; @property (strong, nonatomic) EAGLContext *context;
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator;
- (void)setupGL; - (void)setupGL;
- (void)tearDownGL; - (void)tearDownGL;
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
@end @end
@implementation GameViewController @implementation GameViewController
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
float scale = self.view.contentScaleFactor;
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale);
}
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{ {
UITouch *touch = [[event allTouches] anyObject]; UITouch *touch = [[event allTouches] anyObject];
@@ -31,6 +35,13 @@
float scale = self.view.contentScaleFactor; float scale = self.view.contentScaleFactor;
App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale); App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale);
} }
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
float scale = self.view.contentScaleFactor;
App::I.mouse_up(0, touchLocation.x * scale, touchLocation.y * scale);
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{ {