I am coding an iOS game and I am trying to move down an instance of a Tile (Tile being a subclass of UIImageView.)
Precisely, what I want is having my instance of Tile moving from point A(x,y) to point B(x,y+70) in 0.20s.
I already read that post, that describes a similar problem: change position of the UIImageView
I used the recommended code and adapted it to my case. So here is the code of the method I use:
- (void) moveTileDown {
[UIView animateWithDuration:0.20
delay:1.0
options: UIViewAnimationOptionCurveEaseIn
animations:^{
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y + 70, self.frame.size.width, self.frame.size.height);
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
}
But now, here is my problem. Instead of going from A(x,y) to B(x,y+70), when the method is called, my tile Jumps to C(x,y-70) and comes back to A in 0.20s.
In order to give more info, the moveTileDown method is called from a for loop that takes place in another controller
for (int i=0; i <firstTileRow; i++){
[[[_lines objectAtIndex:i] objectAtIndex:firstTileColumn] moveTileDown];
[[[_lines objectAtIndex:i] objectAtIndex:secondTileColumn] moveTileDown];
}
Any idea?