mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 11:43:19 +08:00
Debugging
This commit is contained in:
committed by
Lukas Klingsbo
parent
39f6e06abb
commit
eeb22ea3ef
@ -63,7 +63,7 @@ abstract class ComponentEffect<T extends Component> {
|
||||
percentage = (currentTime / travelTime).clamp(0.0, 1.0).toDouble();
|
||||
curveProgress = curve.transform(percentage);
|
||||
_updateDriftTime();
|
||||
currentTime = currentTime.clamp(0.0, travelTime).toDouble();
|
||||
//currentTime = currentTime.clamp(0.0, travelTime).toDouble();
|
||||
if (hasFinished()) {
|
||||
onComplete?.call();
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ void effectTest(
|
||||
Vector2 expectedSize,
|
||||
// Only use when checking a value that is not in
|
||||
// the start, end or peak of an iteration
|
||||
double floatRange = 0.000001,
|
||||
double floatRange = 0.0,
|
||||
}) async {
|
||||
expectedPosition ??= Vector2.zero();
|
||||
expectedSize ??= Vector2.all(100.0);
|
||||
@ -38,10 +38,24 @@ void effectTest(
|
||||
await tester.pumpWidget(game.widget);
|
||||
double timeLeft = iterations * duration;
|
||||
while (timeLeft > 0) {
|
||||
final double stepDelta = random.nextInt(100) / 1000;
|
||||
double stepDelta = (50+random.nextInt(50)) / 1000;
|
||||
stepDelta = stepDelta < timeLeft ? stepDelta : timeLeft;
|
||||
game.update(stepDelta);
|
||||
timeLeft -= stepDelta;
|
||||
}
|
||||
if(effect.driftTime > 0) {
|
||||
print("DRIIIIFT ${effect.driftTime} ${effect.travelTime}");
|
||||
}
|
||||
expect(
|
||||
effect.hasFinished(),
|
||||
hasFinished,
|
||||
reason: "Effect.hasFinished() didn't have the expected value",
|
||||
);
|
||||
expect(
|
||||
callback.isCalled,
|
||||
hasFinished,
|
||||
reason: 'Callback was not treated properly',
|
||||
);
|
||||
if (floatRange != 0) {
|
||||
bool acceptableVector(Vector2 vector, Vector2 expectedVector) {
|
||||
return (expectedVector - vector).length < floatRange;
|
||||
@ -64,8 +78,6 @@ void effectTest(
|
||||
expect(component.angle, expectedAngle, reason: "Angle is not correct");
|
||||
expect(component.size, expectedSize, reason: "Size is not correct");
|
||||
}
|
||||
expect(effect.hasFinished(), hasFinished);
|
||||
expect(callback.isCalled, hasFinished);
|
||||
game.update(0.0); // Since effects are removed before they are updated
|
||||
expect(component.effects.isEmpty, hasFinished);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ void main() {
|
||||
MoveEffect effect(bool isInfinite, bool isAlternating) {
|
||||
return MoveEffect(
|
||||
path: path,
|
||||
duration: random.nextDouble() * 100,
|
||||
duration: random.nextInt(100).toDouble(),
|
||||
isInfinite: isInfinite,
|
||||
isAlternating: isAlternating,
|
||||
);
|
||||
|
||||
@ -21,7 +21,7 @@ void main() {
|
||||
RotateEffect effect(bool isInfinite, bool isAlternating) {
|
||||
return RotateEffect(
|
||||
angle: angleArgument,
|
||||
duration: random.nextDouble() * 100,
|
||||
duration: random.nextInt(100).toDouble(),
|
||||
isInfinite: isInfinite,
|
||||
isAlternating: isAlternating,
|
||||
);
|
||||
|
||||
@ -16,7 +16,7 @@ void main() {
|
||||
ScaleEffect effect(bool isInfinite, bool isAlternating) {
|
||||
return ScaleEffect(
|
||||
size: argumentSize,
|
||||
duration: random.nextDouble() * 100,
|
||||
duration: random.nextInt(100).toDouble(),
|
||||
isInfinite: isInfinite,
|
||||
isAlternating: isAlternating,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user