Created
April 24, 2014 09:30
-
-
Save Air-Craft/770e6ac5097a6c67d3ac to your computer and use it in GitHub Desktop.
Quick snippet for actioning touches by touch down index, i.e. in sequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DNF: @implementation { NSMutableArray *_activeTouches } | |
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event | |
{ | |
for (UITouch *t in touches) { | |
NSUInteger idx = _activeTouches.count; | |
[_activeTouches addObject:t]; | |
[self _updateForTouch:t withIndex:idx]; | |
} | |
} | |
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event | |
{ | |
for (UITouch *t in touches) { | |
NSUInteger idx = [_activeTouches indexOfObject:t]; | |
[self _updateForTouch:t withIndex:idx]; | |
} | |
} | |
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event | |
{ | |
[_activeTouches removeObjectsInArray:touches.allObjects]; | |
} | |
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event | |
{ | |
[_activeTouches removeObjectsInArray:touches.allObjects]; | |
} | |
- (void)_updateForTouch:(UITouch *)touch withIndex:(NSUInteger)touchIdx | |
{ | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment