2011-04-15 53 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);