0

I am knew to sphero ios sdk. I would like to know that how could I achieve the movement of object from one point to another in screen of my device while I moving my device from one direction to another using sphero. I have refereed "StreamingAnimation" demo project of sphero. I have also refereed other sample projects of sphero ios sdk also but I am not able to get that how could i achieve the movement of object while I am moving my device from one direction to other. Your reply would be appreciable.

Jekil Patel
  • 403
  • 4
  • 18

1 Answers1

2

Try This

am taking Image to move

UIImageView*animationImage;

UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];

panRecognizer.delegate = self;

[animationImage addGestureRecognizer:panRecognizer];

In Method You Should Implement Like this

-(void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{

   CGPoint translation = [panRecognizer translationInView:self.view];

   CGPoint imageViewPosition = animationImage.center;
   imageViewPosition.x += translation.x;

   imageViewPosition.y += translation.y;
    
   animationImage.center = imageViewPosition;

   [panRecognizer setTranslation:CGPointZero inView:self.view];
        
}
Community
  • 1
  • 1
guptha
  • 529
  • 1
  • 4
  • 9