我有 FrameChangeAnimation 类,它需要多个精灵表和持续时间。所以假设我有 3 个 spritesheet,每个包含 16 个字符块,然后我给 '3' 秒作为持续时间。在将 FrameChangeAnimation 实例作为 CALayer 返回后,我将其附加到屏幕上,并且播放流畅 [16 帧/秒]
现在我想将此动画导出为视频。问题是,当我这次附加 CABasicAnimation 时,持续时间。“持续时间”参数不起作用,所有帧都在一秒钟内播放。
    GTAnimation *an = [[GTAnimation alloc] initWithFrame:CGRectMake(0, 0, videoSize.width, videoSize.height) withFileName:@"Host_Angry_" withSeconds:3.5];
    CALayer *animationLayer = [CALayer layer];
    animationLayer.bounds = CGRectMake(0, 0, videoSize.width, videoSize.height);
    [animationLayer addSublayer:an.animLayer];
    CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"currentFrame"];
    fadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];
    fadeAnimation.toValue = [NSNumber numberWithFloat:45.0];
    fadeAnimation.additive = NO;
    fadeAnimation.removedOnCompletion = NO;
    fadeAnimation.beginTime = 0.0;
    fadeAnimation.duration = 3.5;
    fadeAnimation.repeatCount = HUGE_VAL;
    fadeAnimation.fillMode = kCAFillModeBoth;
    [an.animLayer addAnimation:fadeAnimation forKey:@"currentFrame"];
    CALayer *parentLayer = [CALayer layer];
    CALayer *videoLayer = [CALayer layer];
    videoLayer.bounds = CGRectMake(0, 0, videoSize.width, videoSize.height);
    [parentLayer addSublayer:videoLayer];
    [parentLayer addSublayer:animationLayer];
    videoLayer.anchorPoint =  CGPointMake(0.5, 0.5);
    videoLayer.position = CGPointMake(CGRectGetMidX(parentLayer.bounds), CGRectGetMidY(parentLayer.bounds));
    animationLayer.anchorPoint =  CGPointMake(0.5, 0.5);
    animationLayer.position = CGPointMake(CGRectGetMidX(parentLayer.bounds), CGRectGetMidY(parentLayer.bounds));
    videoComposition.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];