gpt4 book ai didi

iphone - Xcode,iphone - 使图像动画朝特定方向移动

转载 作者:行者123 更新时间:2023-12-03 20:55:15 25 4
gpt4 key购买 nike

我正在创建一个应该在屏幕上移动的动画球。我想让它向屏幕中心移动,就好像它被中心吸引一样。我怎样才能做到这一点?

最佳答案

您可以尝试此代码

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

关于iphone - Xcode,iphone - 使图像动画朝特定方向移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5679952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com