SKSpriteNode erratic swipe?

一笑奈何 提交于 2019-12-06 11:39:00

Instead of [SKAction moveByX:y:] , I used [SKAction moveToY:duration:] which made everything work like charm

Here's the updated handleSwipeUp: method:

- (void)handleSwipeUp:(UISwipeGestureRecognizer *)sender{

 NSLog(@"Node Swiped Up");
 //if (sender.state == UIGestureRecognizerStateEnded)
   //{
    CGPoint touchLocation = [sender locationInView:sender.view];
    touchLocation = [self convertPointFromView:touchLocation];
    SKSpriteNode *touchedNode = (SKSpriteNode *)[self nodeAtPoint:touchLocation];
    if([touchedNode.name isEqualToString:@"awesome"]){
    NSLog(@"Perform Action on AWESOME node");
    **SKAction *moveUp = [SKAction moveToY:(touchedNode.position.y+200) duration:0.5];**
    //SKAction *fade = [SKAction fadeOutWithDuration:0.25];
    SKAction *remove = [SKAction removeFromParent];
    SKAction *sequence = [SKAction sequence:@[moveUp, remove]];
    [touchedNode runAction:sequence];
  }
//}

}

Hope this helps !!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!