6

I am Developing a game in which a UIImageView moves along a Bezier path. I want to provide user interaction to the moving UIimageview so that the user can guide the UIImageView by touching the UIImageView, and dragging it around the path! How does one do that?

enter image description here

0

3 Answers 3

0

Simply use pan gesture and add it to UIImageView and provide your path along which user move it.Pan Gesture

This link might be helpful in understanding and implementing same. Anything else let me know.

19
  • i want to provide user interaction to the moving UIimageview so that user can guide the UIImageView by touching the UIImageview and drag the UIImageview around a Bezier path. Jun 23, 2014 at 12:33
  • So I have provided you with link ,just go through it and see if it work's fine for you. Hope this does else let me know I would find in something else for you
    – nikhil84
    Jun 23, 2014 at 12:35
  • For that bezier path you should provide it as a big line/rope to user so he/she could know along which path he/she has to move that image.
    – nikhil84
    Jun 23, 2014 at 12:37
  • Rest I don't have much idea about your game and plot of it.
    – nikhil84
    Jun 23, 2014 at 12:37
  • i see that link that link is just to move the image around screen i want when user touch the image the image drag and flow a path that is predefined. Jun 23, 2014 at 12:40
0

You have to check whether the touch point coordinates are inside Beizer Path. If it is inside allow UITouch and Movement, else not. Give If Condition accordingly.

1
  • can you please provide me some code or document how to do that. Jun 23, 2014 at 12:52
0

Please try this...

Here selectedImageCat is gobal uiimageview object and touchimgView is select(touched) imageview

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        for (UITouch *touchPoint in touches)
        {
              if(CGRectContainsPoint(touchimgView.frame, [touchPoint locationInView:self.view]))
        selectedImageCat=(UIImageView*)touchimgView;

        }
    }

    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        if (selectedImageCat!=nil)
        {
            CGPoint pt = [[touches anyObject] locationInView:self.view];
            [selectedImageCat setCenter:pt];
        }
    }

    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {


        //here you provide final frame for touchimgView object
    }
1
  • already done it is for the move the image aroung the screen not for selected path Jun 23, 2014 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.