1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
@override bool advance(FlutterActorArtboard artboard, double elapsed) { int lastFullyMixed = -1; double lastMix = 0.0; List<FlareAnimationLayer> completed = []; for (int i = 0; i < _animationLayers.length; i++) { FlareAnimationLayer layer = _animationLayers[i]; layer.mix += elapsed; layer.time += elapsed; lastMix = (_mixSeconds == null || _mixSeconds == 0.0) ? 1.0 : min(1.0, layer.mix / _mixSeconds); if (layer.animation.isLooping) { layer.time %= layer.animation.duration; } _mixTime += elapsed * _speed; layer.animation.apply(layer.time, _artboard, lastMix); if (lastMix == 1.0) { lastFullyMixed = i; } if (layer.time > layer.animation.duration) { completed.add(layer); } } if (lastFullyMixed != -1) { _animationLayers.removeRange(0, lastFullyMixed); } if (_animationName == null && _animationLayers.length == 1 && lastMix == 1.0) { _animationLayers.removeAt(0); } for (FlareAnimationLayer animation in completed) { _animationLayers.remove(animation); onCompleted(animation.name); } return _animationLayers.isNotEmpty; } |