mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +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();
|
percentage = (currentTime / travelTime).clamp(0.0, 1.0).toDouble();
|
||||||
curveProgress = curve.transform(percentage);
|
curveProgress = curve.transform(percentage);
|
||||||
_updateDriftTime();
|
_updateDriftTime();
|
||||||
currentTime = currentTime.clamp(0.0, travelTime).toDouble();
|
//currentTime = currentTime.clamp(0.0, travelTime).toDouble();
|
||||||
if (hasFinished()) {
|
if (hasFinished()) {
|
||||||
onComplete?.call();
|
onComplete?.call();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ void effectTest(
|
|||||||
Vector2 expectedSize,
|
Vector2 expectedSize,
|
||||||
// Only use when checking a value that is not in
|
// Only use when checking a value that is not in
|
||||||
// the start, end or peak of an iteration
|
// the start, end or peak of an iteration
|
||||||
double floatRange = 0.000001,
|
double floatRange = 0.0,
|
||||||
}) async {
|
}) async {
|
||||||
expectedPosition ??= Vector2.zero();
|
expectedPosition ??= Vector2.zero();
|
||||||
expectedSize ??= Vector2.all(100.0);
|
expectedSize ??= Vector2.all(100.0);
|
||||||
@ -38,10 +38,24 @@ void effectTest(
|
|||||||
await tester.pumpWidget(game.widget);
|
await tester.pumpWidget(game.widget);
|
||||||
double timeLeft = iterations * duration;
|
double timeLeft = iterations * duration;
|
||||||
while (timeLeft > 0) {
|
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);
|
game.update(stepDelta);
|
||||||
timeLeft -= 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) {
|
if (floatRange != 0) {
|
||||||
bool acceptableVector(Vector2 vector, Vector2 expectedVector) {
|
bool acceptableVector(Vector2 vector, Vector2 expectedVector) {
|
||||||
return (expectedVector - vector).length < floatRange;
|
return (expectedVector - vector).length < floatRange;
|
||||||
@ -64,8 +78,6 @@ void effectTest(
|
|||||||
expect(component.angle, expectedAngle, reason: "Angle is not correct");
|
expect(component.angle, expectedAngle, reason: "Angle is not correct");
|
||||||
expect(component.size, expectedSize, reason: "Size 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
|
game.update(0.0); // Since effects are removed before they are updated
|
||||||
expect(component.effects.isEmpty, hasFinished);
|
expect(component.effects.isEmpty, hasFinished);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ void main() {
|
|||||||
MoveEffect effect(bool isInfinite, bool isAlternating) {
|
MoveEffect effect(bool isInfinite, bool isAlternating) {
|
||||||
return MoveEffect(
|
return MoveEffect(
|
||||||
path: path,
|
path: path,
|
||||||
duration: random.nextDouble() * 100,
|
duration: random.nextInt(100).toDouble(),
|
||||||
isInfinite: isInfinite,
|
isInfinite: isInfinite,
|
||||||
isAlternating: isAlternating,
|
isAlternating: isAlternating,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -21,7 +21,7 @@ void main() {
|
|||||||
RotateEffect effect(bool isInfinite, bool isAlternating) {
|
RotateEffect effect(bool isInfinite, bool isAlternating) {
|
||||||
return RotateEffect(
|
return RotateEffect(
|
||||||
angle: angleArgument,
|
angle: angleArgument,
|
||||||
duration: random.nextDouble() * 100,
|
duration: random.nextInt(100).toDouble(),
|
||||||
isInfinite: isInfinite,
|
isInfinite: isInfinite,
|
||||||
isAlternating: isAlternating,
|
isAlternating: isAlternating,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ void main() {
|
|||||||
ScaleEffect effect(bool isInfinite, bool isAlternating) {
|
ScaleEffect effect(bool isInfinite, bool isAlternating) {
|
||||||
return ScaleEffect(
|
return ScaleEffect(
|
||||||
size: argumentSize,
|
size: argumentSize,
|
||||||
duration: random.nextDouble() * 100,
|
duration: random.nextInt(100).toDouble(),
|
||||||
isInfinite: isInfinite,
|
isInfinite: isInfinite,
|
||||||
isAlternating: isAlternating,
|
isAlternating: isAlternating,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user