将动画从艺术家转换为代码



在我们的开发过程中,我们遇到了许多实例,艺术家/设计会模拟动画,而开发人员将任务转换为代码 - 无论是Uiview Animations还是COCOS2D之类的游戏引擎中的CCactions。

问题是,我们没有一个很好的方法来将艺术家/设计师提供的动画(通常是以闪光/后的效果或类似工具)直接转变为代码。开发人员必须花费大量时间来弄清确切的动画参数,并以看起来像这样的代码:

CAAnimationGroup *(^groupedAnimation)(CGMutablePathRef curvedPath, NSTimeInterval delay) = ^(CGMutablePathRef curvedPath, NSTimeInterval delay) {
    CGFloat moveTime = 1.6;
    CABasicAnimation *scaling = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    scaling.fromValue = @1.;
    scaling.toValue = @0.05;
    scaling.beginTime = delay;
    scaling.duration = moveTime;
    scaling.removedOnCompletion = NO;
    scaling.fillMode = kCAFillModeForwards;
    scaling.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
    CABasicAnimation *opacity = [CABasicAnimation animationWithKeyPath:@"opacity"];
    opacity.fromValue = @1.;
    opacity.toValue = @0.1;
    opacity.beginTime = delay + moveTime-0.6;
    opacity.duration = 0.5;
    opacity.removedOnCompletion = NO;
    opacity.fillMode = kCAFillModeForwards;
    opacity.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    CAKeyframeAnimation *path = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    path.beginTime = delay;
    path.duration = moveTime;
    path.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    path.path = curvedPath;
    path.calculationMode = kCAAnimationPaced;
    path.removedOnCompletion = NO;
    path.fillMode = kCAFillModeForwards;
    CAAnimationGroup *group = [CAAnimationGroup animation];
    group.animations = @[scaling, opacity, path];
    group.beginTime = 0;
    group.duration = moveTime+delay;
    group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
    group.removedOnCompletion = NO;
    group.fillMode = kCAFillModeForwards;
    return group;
};

在代码中弄清楚这些动画的参数是一个非常手动的过程,涉及大量的动画模拟,并在看起来不错的值上迭代地缩小。通常非常耗时且乏味。

有更好的过程吗?该行业标准是什么?

谢谢

请看一下SpriteKit场景编辑,

在Xcode->创建新项目 -> Game -> Game Technology = SpriteKit

然后,通过单击项目Navigator中的Extension .SK

单击文件打开场景编辑器

您可以实验动画并实现上述无需单行代码

相关内容

  • 没有找到相关文章

最新更新