How to abruptly end an animation?

i am making a game in which when user makes a move the source and destination squares light up in an animation.The animation duration is 1 sec.

The problem is when user taps on forward button too quickly all source and destination squares light up leading to many light up squares happening due to second animation starting before the first one ends.

How can i abruptly end a animation when its duration is not over.

animation function code :-

[UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:value];
    [UIView setAnimationRepeatCount:1];
   // [UIView setAnimationRepeatAutoreverses:YES];

    [self.view viewWithTag:(src+1)+2000].backgroundColor=[UIColor orangeColor];
    [self.view viewWithTag:(src+1)+2000].backgroundColor=[UIColor clearColor];
    [self.view viewWithTag:(dest+1)+2000].backgroundColor=[UIColor orangeColor]; 
    [self.view viewWithTag:(dest+1)+2000].backgroundColor=[UIColor clearColor];
    [UIView commitAnimations];

Note :- I accept down vote as a healthy way of criticism but do write the reason so that i can improve



#import <QuartzCore/QuartzCore.h>


[myView.layer removeAllAnimations];

hope it helps. happy coding :)

Need Your Help

How can I read child node names and their values in XML without specifying the tag name?

javascript xml dom

Here, I want to loop through the &lt;detail&gt; elements. Although I can specify the &lt;detail&gt; tag name in my code, I can't use the tag names of the children. I want to know the tag names of...