Created
June 18, 2011 01:49
-
-
Save britg/1032712 to your computer and use it in GitHub Desktop.
MultistrokeGestureRecognizer-iOS
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
- (void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | |
UITouch *touch = [touches anyObject]; | |
CGPoint point = [touch locationInView: [touch view]]; | |
[glyphDetector addPoint:point]; | |
} | |
- (void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { | |
UITouch *touch = [touches anyObject]; | |
CGPoint point = [touch locationInView: [touch view]]; | |
[glyphDetector addPoint:point]; | |
} | |
- (void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { | |
UITouch *touch = [touches anyObject]; | |
CGPoint point = [touch locationInView: [touch view]]; | |
[glyphDetector addPoint:point]; | |
[glyphDetector detectGlyph]; | |
} |
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
[ | |
[ [345,9], [345,87] ], | |
[ [351,8], [363,8], [372, 9], [380, 11], [386, 14], [391, 17], [394, 22], [397, 28], [399,34], [400,42], [400,50], [400,56], [399,61], [397,66], [394,70], [391,74], [386,78], [382,81], [377,83], [372,85], [367,87], [360,87], [355,88], [349,87] ] | |
] |
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
// The Detector delegate should implement this method: | |
- (void)glyphDetected:(WTMGlyph *)glyph withScore:(float)score { | |
// Go forth and do awesome things | |
} |
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
#import "WTMGlyphDetector.h" | |
// MyDetectingThing.h | |
@interface SpellInputLayer : CCLayer <WTMGlyphDelegate> { | |
WTMGlyphDetector *glyphDetector; | |
} | |
// MyDetectingThing.m | |
// An example method in an object that initializes the | |
// gesture detector | |
- (void)initGestureDetector { | |
// Initialize | |
glyphDetector = [WTMGlyphDetector detector]; | |
// Assign the detection delegate | |
glyphDetector.delegate = self; | |
// Add initial glyph templates from JSON files | |
// Rinse and repeat for each of the gestures you want to detect | |
NSData *jsonData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"D" ofType:@"json"]]; | |
[self addGlyphFromJSON:jsonData name:@"D"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a small mistake here: [self addGlyphFromJSON:jsonData name:@"D"];
It should be
[glyphDetector addGlyphFromJSON:jsonData name:@"D"];