Frage

I am working on a game where i'm allowing user to drag and drop image(UIImageView) on the target image(UIImageView), and i'm achieving this using (CGRectIntersectsRect) in TouchesEnded.

Now i need to do the same in (TouchesMoved), i already checked (CGRectIntersectsRect) for both images conditionally, if true i'm making both image frames equal and disabling user interaction to that image, it's indicating but image is still draggable till (TouchesEnded) called.

I'm using below listed code to end dragging in (TouchesMoved):

if([self distanceBetweenPoint:fruit1.center andPoint:fruit1b.center]<=45) { fruit1.frame = fruit1b.frame; fruit1.userInteractionEnabled = FALSE; }

Can anyone give me a solutions for this problem?

War es hilfreich?

Lösung

You can make a global BOOL endDragging and when your condition is met you just return the touchesMoved.

It works , I just tested it, you won't be able to move the image after the condition is met.

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
 if(endDragging)
  return;

 //do stuff

}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top