I am trying to show a simple point moving. I set up a layer, set the bounds, position and color, and then use CAAnimation to show it moving
CALayer *l = [CALayer layer];
l.bounds = CGRectMake(0,0,20,20);
l.position = CGPointMake(x,y);
l.cornerRadius = 10;
l.backgroundColor = [UIColor blueColor].CGColor;
[self.theView.layer addSublayer:l];
CABasicAnimation *anim1 = [CABasicAnimation animationWithKeyPath:@"position"];
anim1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
CGPoint to = CGPointMake(x+dx, y+dy);
anim1.fromValue = [l valueForKey:@"position"];
anim1.toValue = [NSValue valueWithCGPoint:to];
l.position = to;
anim1.duration = 3.0;
When I run this, I see two blue circles moving. I want to see one circle moving from (x,y) to (x+dx,y+dy). Could someone clue me in on what I'm doing wrong?
thanks