How to animate transition from current position?

Posts: 75
Joined: 2009.01
Post: #1
EDIT: I meant: How to "translate" from current position?

I've been trying to figure out how to translate a UIImageView from its current position since the current position keeps changing in my app.

I have a tile map, let's say 10x10 with a tile size of 32.
I have four directional swipes: left, right, up, and down each which causes a moveLeft, moveRight, moveUp, and moveDown function.
Each one of those functions has the following code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform = CGAffineTransformMakeTranslation(greenCurrentX * TILE_SIZE, greenCurrentY * TILE_SIZE);
greenBlock.transform = transform;
[UIView commitAnimations];

This code ONLY works after the first initial animation.
If I were to swipe in any direction, the block would go to some random (not really, more like unintentional) tile.
If I swipe AGAIN it starts moving from tile to tile like I want it to but the problem is the FIRST translation.
I've just begun using animations so bare with me please.

I also thought of using:
CGAffineTransform transform = CGAffineTransformMakeTranslation(blah blah, blah blah);
CGAffineTransform transform2 = CGAffineTransformTranslate(transform, blah blah, blah blah);

But it's doing a lot of unexpected things (for me that is).

Is there a way to translate a UIImageView from its currentPosition for my purpose?

Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  current app approval lead time? mraycpb 9 7,883 Apr 1, 2011 04:16 PM
Last Post: flydog
  How To Animate a sliding of a circle on touchesMoved. syednab 0 2,542 Oct 18, 2008 09:55 AM
Last Post: syednab