add touch begin/end on iOS
This commit is contained in:
@@ -15,15 +15,19 @@
|
||||
}
|
||||
@property (strong, nonatomic) EAGLContext *context;
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator;
|
||||
- (void)setupGL;
|
||||
- (void)tearDownGL;
|
||||
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
|
||||
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
|
||||
@end
|
||||
|
||||
@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
|
||||
{
|
||||
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<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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user