I'm trying with touch events like this;
[_movie addEventListener:@selector(swiped:) atObject:self
forType:SP_EVENT_TYPE_TOUCH];
But this -(void)swiped; method is getting called several times.
I need to detect a swipe gesture done upwards.
I tried this
-(void)swiped:(SPTouchEvent *)event{
NSArray *touches = [[event touchesWithTarget:_movie andPhase:SPTouchPhaseMoved] allObjects];
if([touches count] > 0){
SPTouch *touch = [touches objectAtIndex:0];
SPPoint *currentPos = [touch locationInSpace:_movie.parent];
SPPoint *previousPos = [touch previousLocationInSpace:_movie.parent];
if((previousPos.y - currentPos.y) > 10){
NSLog(@"JUMP");
}
NSLog(@"\nPRe: %f -x | %f -y ",previousPos.x,previousPos.y);
NSLog(@"\nCurr: %f -x | %f -y ",currentPos.x,currentPos.y);
}
}
But, "JUMP" is getting printed several times and I cant do some logic there.
Please help