mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-04 04:47:13 +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(
 | 
			
		||||
      effects: [move2, rotate],
 | 
			
		||||
      isAlternating: false,
 | 
			
		||||
      isInfinite: true,
 | 
			
		||||
      isInfinite: false,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    final sequence = SequenceEffect(
 | 
			
		||||
      effects: [move1, scale, combination],
 | 
			
		||||
      isInfinite: true,
 | 
			
		||||
      isAlternating: false,
 | 
			
		||||
      isInfinite: 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) {
 | 
			
		||||
    if (isAlternating && !effect.isAlternating && effect.isMax()) {
 | 
			
		||||
      // Make the effect go in reverse
 | 
			
		||||
 | 
			
		||||
@ -51,7 +51,7 @@ abstract class ComponentEffect<T extends Component> {
 | 
			
		||||
    if (isAlternating) {
 | 
			
		||||
      curveDirection = isMax() ? -1 : (isMin() ? 1 : curveDirection);
 | 
			
		||||
    } else if (isInfinite && isMax()) {
 | 
			
		||||
      currentTime = 0.0;
 | 
			
		||||
      reset();
 | 
			
		||||
    }
 | 
			
		||||
    final driftMultiplier = (isAlternating && isMax() ? 2 : 1) * curveDirection;
 | 
			
		||||
    if (!hasFinished()) {
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,10 @@ class SequenceEffect extends PositionComponentEffect {
 | 
			
		||||
      effects.every((effect) => effect.component == null),
 | 
			
		||||
      "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
 | 
			
		||||
@ -63,9 +67,9 @@ class SequenceEffect extends PositionComponentEffect {
 | 
			
		||||
      _driftModifier = currentEffect.driftTime;
 | 
			
		||||
      _currentIndex++;
 | 
			
		||||
      final iterationSize = isAlternating ? effects.length * 2 : effects.length;
 | 
			
		||||
      if (_currentIndex != 0
 | 
			
		||||
          && _currentIndex == iterationSize
 | 
			
		||||
          && (currentEffect.isAlternating ||
 | 
			
		||||
      if (_currentIndex != 0 &&
 | 
			
		||||
          _currentIndex == iterationSize &&
 | 
			
		||||
          (currentEffect.isAlternating ||
 | 
			
		||||
              currentEffect.isAlternating == isAlternating)) {
 | 
			
		||||
        isInfinite ? reset() : dispose();
 | 
			
		||||
        return;
 | 
			
		||||
@ -92,10 +96,12 @@ class SequenceEffect extends PositionComponentEffect {
 | 
			
		||||
  @override
 | 
			
		||||
  void reset() {
 | 
			
		||||
    super.reset();
 | 
			
		||||
    effects.forEach((e) => e.reset());
 | 
			
		||||
    if (component != null) {
 | 
			
		||||
      component.position = originalPosition;
 | 
			
		||||
      component.angle = originalAngle;
 | 
			
		||||
      component.size = originalSize;
 | 
			
		||||
      initialize(component);
 | 
			
		||||
    //effects.forEach((e) => e.reset());
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user