2011-04-15 61 views

回答

2

你可以试试这个代码

[UIView beginAnimations:nil context:NULL]; //starting Animation 

[UIView setAnimationDuration:1.0]; 
[UIView setAnimationRepeatCount:10]; 
[UIView setAnimationRrepeatAutoreverses:YES]; 

CGPoint position = 200.0f; 
position.y = 200.0f; 
position.x = 150.0f; 
img.center = position; 

[UIView commitAnimations]; 

如果是cocos2d的,您可以使用Move方法,

id move = [CCMoveTo actionWithDuration:3 position:ccp(160,240); 
[sprite runAction:move]; 
+0

ü`CGPoint位置= 200.0f;`ISN没错,对吧?另外,你不需要`CGPointMake(160.0f,240.0f)`作为中心吗? – 2011-04-15 17:58:47

1
image.center = CGPointMake(image.center.x + 10, image.center.y);