From 2e8c0d08655a51d1418c3bfed20fcbf347628885 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 8 May 2017 00:26:34 +0100 Subject: [PATCH] add touch begin/end on iOS --- PanoPainter/GameViewController.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/PanoPainter/GameViewController.m b/PanoPainter/GameViewController.m index 9a6d8d5..aa19717 100644 --- a/PanoPainter/GameViewController.m +++ b/PanoPainter/GameViewController.m @@ -15,15 +15,19 @@ } @property (strong, nonatomic) EAGLContext *context; -- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator; - (void)setupGL; - (void)tearDownGL; -//- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; @end @implementation GameViewController +- (void)touchesBegan:(NSSet *)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 *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; @@ -31,6 +35,13 @@ float scale = self.view.contentScaleFactor; App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale); } +-(void)touchesEnded:(NSSet *)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)coordinator {