mirror of
https://github.com/rive-app/rive-flutter.git
synced 2026-03-13 08:32:10 +08:00
Fixing condition with exit time.
This commit is contained in:
@@ -42,16 +42,15 @@ class StateTransition extends StateTransitionBase {
|
||||
}
|
||||
}
|
||||
|
||||
double exitTimeSeconds(LayerState stateFrom) {
|
||||
if (exitTime == 0) {
|
||||
return 0;
|
||||
}
|
||||
double exitTimeSeconds(LayerState stateFrom, {bool absolute = false}) {
|
||||
if ((flags & StateTransitionFlags.exitTimeIsPercentage) != 0) {
|
||||
var animationDuration = 0.0;
|
||||
var start = 0.0;
|
||||
if (stateFrom is AnimationState) {
|
||||
start = absolute ? stateFrom.animation?.startSeconds ?? 0 : 0;
|
||||
animationDuration = stateFrom.animation?.durationSeconds ?? 0;
|
||||
}
|
||||
return exitTime / 100 * animationDuration;
|
||||
return start + exitTime / 100 * animationDuration;
|
||||
} else {
|
||||
return exitTime / 1000;
|
||||
}
|
||||
|
||||
@@ -46,4 +46,9 @@ class Bone extends BoneBase {
|
||||
set y(double value) {
|
||||
throw UnsupportedError('not expected to set y on a bone.');
|
||||
}
|
||||
|
||||
@override
|
||||
bool validate() {
|
||||
return super.validate() && (coreType != BoneBase.typeKey || parent is Bone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class LayerController {
|
||||
LayerController(this.layer) {
|
||||
_changeState(layer.entryState);
|
||||
}
|
||||
bool _changeState(LayerState? state) {
|
||||
bool _changeState(LayerState? state, {StateTransition? transition}) {
|
||||
if (state == _currentState) {
|
||||
return false;
|
||||
}
|
||||
@@ -53,8 +53,8 @@ class LayerController {
|
||||
}
|
||||
}
|
||||
for (int i = 0; updateState(inputValues); i++) {
|
||||
machineController.advanceInputs();
|
||||
if (i == 100) {
|
||||
machineController.advanceInputs();
|
||||
print('StateMachineController.apply exceeded max iterations.');
|
||||
return false;
|
||||
}
|
||||
@@ -109,13 +109,14 @@ class LayerController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valid && _changeState(transition.stateTo)) {
|
||||
if (valid && _changeState(transition.stateTo, transition: transition)) {
|
||||
_transition = transition;
|
||||
_stateFrom = stateFrom;
|
||||
if (transition.pauseOnExit &&
|
||||
transition.enableExitTime &&
|
||||
_animationInstance != null) {
|
||||
_animationInstance!.time = transition.exitTimeSeconds(stateFrom);
|
||||
_animationInstance!.time =
|
||||
transition.exitTimeSeconds(stateFrom, absolute: true);
|
||||
}
|
||||
if (_mix != 0) {
|
||||
_holdAnimationFrom = transition.pauseOnExit;
|
||||
@@ -160,6 +161,7 @@ class StateMachineController extends RiveAnimationController<CoreContext> {
|
||||
for (final layer in stateMachine.layers) {
|
||||
layerControllers.add(LayerController(layer));
|
||||
}
|
||||
advanceInputs();
|
||||
return super.init(core);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user