简体   繁体   English

iPhone:为动画生成随机路径

[英]iPhone : generating random paths for animations

I am able to my animation in a linear path. 我能够以线性路径播放动画。 How do I get program them to move in a random path? 我该如何编程以使其在随机路径中移动? I read developer's "move me" sample codes but it wasn't clear enough. 我阅读了开发人员的“ move me”示例代码,但还不够清楚。 Are there other tutorials out there for animations such as these? 还有其他诸如此类的动画教程吗?

//Loading the array with images
        NSArray *myImages = [NSArray arrayWithObjects:
                             [UIImage imageNamed:@"enemyball.png"],
                             [UIImage imageNamed:@"playerball.png"]
                             , nil];

        //animation of images
        UIImageView *animatedView =[[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 50.0, 50.0)];

        animatedView.animationImages = myImages;
        animatedView.animationDuration = 0.25; // seconds
        animatedView.animationRepeatCount = 0; //0 loops for ever/noted
        [animatedView startAnimating];
        [self addSubview:animatedView];


        //animation movement
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:4];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

        [UIView setAnimationRepeatCount:INFINITY];
        [UIView setAnimationRepeatAutoreverses:YES];
        [UIView setAnimationBeginsFromCurrentState:YES];

        CGAffineTransform transform = CGAffineTransformMakeTranslation(100, 0);
        animatedView.transform = transform;

        [UIView commitAnimations];

I don't know if you are asking about animation techniques or if you are just asking about random walks. 我不知道您是在问动画技术还是在问随机游走。 If the later, the wiki page is a good start. 如果是更高版本,则Wiki页面是一个好的开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM