mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-11 18:11:12 +08:00
Fix last bugs from rebase
This commit is contained in:
@@ -73,14 +73,14 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
final combination = CombinedEffect(
|
final combination = CombinedEffect(
|
||||||
effects: [move2, rotate],
|
effects: [move2, rotate],
|
||||||
isAlternating: false,
|
isAlternating: false,
|
||||||
isInfinite: true,
|
isInfinite: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
final sequence = SequenceEffect(
|
final sequence = SequenceEffect(
|
||||||
effects: [move1, scale, combination],
|
effects: [move1, scale, combination],
|
||||||
isInfinite: true,
|
isInfinite: false,
|
||||||
isAlternating: false,
|
isAlternating: true,
|
||||||
);
|
);
|
||||||
greenSquare.addEffect(combination);
|
greenSquare.addEffect(sequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ class CombinedEffect extends PositionComponentEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool hasFinished() {
|
||||||
|
return super.hasFinished() && effects.every((e) => e.hasFinished());
|
||||||
|
}
|
||||||
|
|
||||||
void _maybeReverse(PositionComponentEffect effect) {
|
void _maybeReverse(PositionComponentEffect effect) {
|
||||||
if (isAlternating && !effect.isAlternating && effect.isMax()) {
|
if (isAlternating && !effect.isAlternating && effect.isMax()) {
|
||||||
// Make the effect go in reverse
|
// Make the effect go in reverse
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ abstract class ComponentEffect<T extends Component> {
|
|||||||
if (isAlternating) {
|
if (isAlternating) {
|
||||||
curveDirection = isMax() ? -1 : (isMin() ? 1 : curveDirection);
|
curveDirection = isMax() ? -1 : (isMin() ? 1 : curveDirection);
|
||||||
} else if (isInfinite && isMax()) {
|
} else if (isInfinite && isMax()) {
|
||||||
currentTime = 0.0;
|
reset();
|
||||||
}
|
}
|
||||||
final driftMultiplier = (isAlternating && isMax() ? 2 : 1) * curveDirection;
|
final driftMultiplier = (isAlternating && isMax() ? 2 : 1) * curveDirection;
|
||||||
if (!hasFinished()) {
|
if (!hasFinished()) {
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ class SequenceEffect extends PositionComponentEffect {
|
|||||||
effects.every((effect) => effect.component == null),
|
effects.every((effect) => effect.component == null),
|
||||||
"No effects can be added to components from the start",
|
"No effects can be added to components from the start",
|
||||||
);
|
);
|
||||||
|
assert(
|
||||||
|
effects.every((effect) => !effect.isInfinite),
|
||||||
|
"No effects added to the sequence can be infinite",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -63,9 +67,9 @@ class SequenceEffect extends PositionComponentEffect {
|
|||||||
_driftModifier = currentEffect.driftTime;
|
_driftModifier = currentEffect.driftTime;
|
||||||
_currentIndex++;
|
_currentIndex++;
|
||||||
final iterationSize = isAlternating ? effects.length * 2 : effects.length;
|
final iterationSize = isAlternating ? effects.length * 2 : effects.length;
|
||||||
if (_currentIndex != 0
|
if (_currentIndex != 0 &&
|
||||||
&& _currentIndex == iterationSize
|
_currentIndex == iterationSize &&
|
||||||
&& (currentEffect.isAlternating ||
|
(currentEffect.isAlternating ||
|
||||||
currentEffect.isAlternating == isAlternating)) {
|
currentEffect.isAlternating == isAlternating)) {
|
||||||
isInfinite ? reset() : dispose();
|
isInfinite ? reset() : dispose();
|
||||||
return;
|
return;
|
||||||
@@ -92,10 +96,12 @@ class SequenceEffect extends PositionComponentEffect {
|
|||||||
@override
|
@override
|
||||||
void reset() {
|
void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
|
effects.forEach((e) => e.reset());
|
||||||
|
if (component != null) {
|
||||||
component.position = originalPosition;
|
component.position = originalPosition;
|
||||||
component.angle = originalAngle;
|
component.angle = originalAngle;
|
||||||
component.size = originalSize;
|
component.size = originalSize;
|
||||||
initialize(component);
|
initialize(component);
|
||||||
//effects.forEach((e) => e.reset());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user