开发者

Xcode, iphone - Make image animation move in specific direction [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 4 years ago.

开发者_开发百科 Improve this question

I'm creating an animated ball which should move across the screen. I want to make it move towards the center of the screen as if it is attracted by the center. How can I do this?


You can try this code

[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];

If it is cocos2d,You can use Move method,

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜