X code,iphone - 在特定的方向进行动漫形象的举动 [英] Xcode, iphone - Make image animation move in specific direction
本文介绍了X code,iphone - 在特定的方向进行动漫形象的举动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建一个动画球应在屏幕上移动。我想使它朝向屏幕的中心移动,就好像它是由中心吸引。我怎样才能做到这一点?
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?
推荐答案
您可以试试这个code
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];
如果是cocos2d的,您可以使用Move方法,
If it is cocos2d,You can use Move method,
id move = [CCMoveTo actionWithDuration:3 position:ccp(160,240);
[sprite runAction:move];
这篇关于X code,iphone - 在特定的方向进行动漫形象的举动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文