mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
Fixed some Sequence bugs
This commit is contained in:
@ -3,13 +3,12 @@ import 'package:flame/effects/move_effect.dart';
|
|||||||
import 'package:flame/effects/scale_effect.dart';
|
import 'package:flame/effects/scale_effect.dart';
|
||||||
import 'package:flame/effects/rotate_effect.dart';
|
import 'package:flame/effects/rotate_effect.dart';
|
||||||
import 'package:flame/gestures.dart';
|
import 'package:flame/gestures.dart';
|
||||||
|
import 'package:flame/extensions/offset.dart';
|
||||||
import 'package:flame/extensions/vector2.dart';
|
import 'package:flame/extensions/vector2.dart';
|
||||||
import 'package:flame/flame.dart';
|
import 'package:flame/flame.dart';
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import './square.dart';
|
import './square.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@ -32,10 +31,8 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onTapUp(TapUpDetails details) {
|
void onTapUp(TapUpDetails details) {
|
||||||
final dx = details.localPosition.dx;
|
|
||||||
final dy = details.localPosition.dy;
|
|
||||||
greenSquare.clearEffects();
|
greenSquare.clearEffects();
|
||||||
final Vector2 currentTap = Vector2(dx, dy);
|
final Vector2 currentTap = details.localPosition.toVector2();
|
||||||
|
|
||||||
final move = MoveEffect(
|
final move = MoveEffect(
|
||||||
path: [
|
path: [
|
||||||
@ -43,23 +40,22 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
currentTap - Vector2(50, 20),
|
currentTap - Vector2(50, 20),
|
||||||
currentTap + Vector2.all(30),
|
currentTap + Vector2.all(30),
|
||||||
],
|
],
|
||||||
duration: 5.0,
|
duration: 4.0,
|
||||||
curve: Curves.linear,
|
curve: Curves.bounceInOut,
|
||||||
isInfinite: false,
|
isInfinite: false,
|
||||||
isAlternating: false,
|
isAlternating: false,
|
||||||
onComplete: () => print(DateTime.now()),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final scale = ScaleEffect(
|
final scale = ScaleEffect(
|
||||||
size: Vector2(dx, dy),
|
size: currentTap,
|
||||||
speed: 250.0,
|
speed: 200.0,
|
||||||
curve: Curves.linear,
|
curve: Curves.linear,
|
||||||
isInfinite: false,
|
isInfinite: false,
|
||||||
isAlternating: false,
|
isAlternating: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
final rotate = RotateEffect(
|
final rotate = RotateEffect(
|
||||||
angle: (dx + dy) % pi,
|
angle: currentTap.angleTo(Vector2.all(100)),
|
||||||
duration: 3,
|
duration: 3,
|
||||||
curve: Curves.decelerate,
|
curve: Curves.decelerate,
|
||||||
isInfinite: false,
|
isInfinite: false,
|
||||||
|
|||||||
@ -4,13 +4,12 @@ import 'package:flame/effects/scale_effect.dart';
|
|||||||
import 'package:flame/effects/rotate_effect.dart';
|
import 'package:flame/effects/rotate_effect.dart';
|
||||||
import 'package:flame/effects/sequence_effect.dart';
|
import 'package:flame/effects/sequence_effect.dart';
|
||||||
import 'package:flame/gestures.dart';
|
import 'package:flame/gestures.dart';
|
||||||
|
import 'package:flame/extensions/offset.dart';
|
||||||
import 'package:flame/extensions/vector2.dart';
|
import 'package:flame/extensions/vector2.dart';
|
||||||
import 'package:flame/flame.dart';
|
import 'package:flame/flame.dart';
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import './square.dart';
|
import './square.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@ -30,23 +29,22 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onTapUp(TapUpDetails details) {
|
void onTapUp(TapUpDetails details) {
|
||||||
final dx = details.localPosition.dx;
|
final Vector2 currentTap = details.localPosition.toVector2();
|
||||||
final dy = details.localPosition.dy;
|
|
||||||
greenSquare.clearEffects();
|
greenSquare.clearEffects();
|
||||||
|
|
||||||
final move1 = MoveEffect(
|
final move1 = MoveEffect(
|
||||||
path: [Vector2(dx, dy)],
|
path: [currentTap],
|
||||||
speed: 250.0,
|
speed: 250.0,
|
||||||
curve: Curves.bounceInOut,
|
curve: Curves.bounceInOut,
|
||||||
isInfinite: false,
|
isInfinite: false,
|
||||||
isAlternating: false,
|
isAlternating: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
final move2 = MoveEffect(
|
final move2 = MoveEffect(
|
||||||
path: [
|
path: [
|
||||||
Vector2(dx, dy + 50),
|
currentTap + Vector2(0, 50),
|
||||||
Vector2(dx - 50, dy - 50),
|
currentTap + Vector2(-50, -50),
|
||||||
Vector2(dx + 50, dy),
|
currentTap + Vector2(50, 0),
|
||||||
],
|
],
|
||||||
speed: 150.0,
|
speed: 150.0,
|
||||||
curve: Curves.easeIn,
|
curve: Curves.easeIn,
|
||||||
@ -55,7 +53,7 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final scale = ScaleEffect(
|
final scale = ScaleEffect(
|
||||||
size: Vector2(dx, dy),
|
size: currentTap,
|
||||||
speed: 100.0,
|
speed: 100.0,
|
||||||
curve: Curves.easeInCubic,
|
curve: Curves.easeInCubic,
|
||||||
isInfinite: false,
|
isInfinite: false,
|
||||||
@ -63,12 +61,11 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final rotate = RotateEffect(
|
final rotate = RotateEffect(
|
||||||
angle: (dx + dy) % pi,
|
angle: currentTap.angleTo(Vector2.all(100)),
|
||||||
duration: 0.8,
|
duration: 0.8,
|
||||||
curve: Curves.decelerate,
|
curve: Curves.decelerate,
|
||||||
isInfinite: false,
|
isInfinite: false,
|
||||||
isAlternating: false,
|
isAlternating: false,
|
||||||
onComplete: () => print("rotation complete"),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final combination = CombinedEffect(
|
final combination = CombinedEffect(
|
||||||
@ -79,11 +76,11 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final sequence = SequenceEffect(
|
final sequence = SequenceEffect(
|
||||||
effects: [move1, scale, combination],
|
effects: [move1, scale, move2],
|
||||||
isInfinite: false,
|
isInfinite: false,
|
||||||
isAlternating: true,
|
isAlternating: true,
|
||||||
);
|
);
|
||||||
sequence.onComplete = () => print("sequence complete");
|
sequence.onComplete = () => print("sequence complete");
|
||||||
greenSquare.addEffect(sequence);
|
greenSquare.addEffect(combination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,19 +28,21 @@ class CombinedEffect extends PositionComponentEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initialize(PositionComponent _comp) {
|
void initialize(PositionComponent component) {
|
||||||
super.initialize(_comp);
|
super.initialize(component);
|
||||||
effects.forEach((effect) {
|
effects.forEach((effect) {
|
||||||
effect.initialize(_comp);
|
effect.initialize(component);
|
||||||
final isSameSize = effect.endSize == _comp.size;
|
endPosition = effect.endPosition;
|
||||||
final isSamePosition = effect.endPosition == _comp.position;
|
endAngle = effect.endAngle;
|
||||||
final isSameAngle = effect.endAngle == _comp.angle;
|
endSize = effect.endSize;
|
||||||
endSize = isSameSize ? endSize : effect.endSize;
|
|
||||||
endPosition = isSamePosition ? endPosition : effect.endPosition;
|
|
||||||
endAngle = isSameAngle ? endAngle : effect.endAngle;
|
|
||||||
peakTime = max(peakTime ?? 0,
|
peakTime = max(peakTime ?? 0,
|
||||||
effect.iterationTime + offset * effects.indexOf(effect));
|
effect.iterationTime + offset * effects.indexOf(effect));
|
||||||
});
|
});
|
||||||
|
if (isAlternating) {
|
||||||
|
endPosition = originalPosition;
|
||||||
|
endAngle = originalAngle;
|
||||||
|
endSize = originalSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -57,13 +59,11 @@ class CombinedEffect extends PositionComponentEffect {
|
|||||||
@override
|
@override
|
||||||
void reset() {
|
void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
if (component != null) {
|
component?.position = originalPosition;
|
||||||
component.position = originalPosition;
|
component?.angle = originalAngle;
|
||||||
component.angle = originalAngle;
|
component?.size = originalSize;
|
||||||
component.size = originalSize;
|
|
||||||
initialize(component);
|
|
||||||
}
|
|
||||||
effects.forEach((effect) => effect.reset());
|
effects.forEach((effect) => effect.reset());
|
||||||
|
initialize(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -63,14 +63,17 @@ abstract class ComponentEffect<T extends Component> {
|
|||||||
}
|
}
|
||||||
if (!hasFinished()) {
|
if (!hasFinished()) {
|
||||||
currentTime += (dt + driftTime) * curveDirection;
|
currentTime += (dt + driftTime) * curveDirection;
|
||||||
currentTime = (currentTime * 10000000).floor() / 10000000;
|
|
||||||
percentage = (currentTime / peakTime).clamp(0.0, 1.0).toDouble();
|
percentage = (currentTime / peakTime).clamp(0.0, 1.0).toDouble();
|
||||||
curveProgress = curve.transform(percentage);
|
curveProgress = curve.transform(percentage);
|
||||||
_updateDriftTime();
|
_updateDriftTime();
|
||||||
currentTime = currentTime.clamp(0.0, peakTime).toDouble();
|
currentTime = currentTime.clamp(0.0, peakTime).toDouble();
|
||||||
if (hasFinished()) {
|
if (hasFinished()) {
|
||||||
onComplete?.call();
|
onComplete?.call();
|
||||||
_setComponentToEndState();
|
// Set the component to the exact end state if this component is the
|
||||||
|
// root component (not inside another component).
|
||||||
|
if (component.effects.contains(this)) {
|
||||||
|
_setComponentToEndState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +183,7 @@ abstract class SimplePositionComponentEffect extends PositionComponentEffect {
|
|||||||
bool isRelative = false,
|
bool isRelative = false,
|
||||||
void Function() onComplete,
|
void Function() onComplete,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
duration != null || speed != null,
|
(duration != null) ^ (speed != null),
|
||||||
"Either speed or duration necessary",
|
"Either speed or duration necessary",
|
||||||
),
|
),
|
||||||
super(
|
super(
|
||||||
|
|||||||
@ -24,6 +24,7 @@ class MoveEffect extends SimplePositionComponentEffect {
|
|||||||
List<Vector2Percentage> _percentagePath;
|
List<Vector2Percentage> _percentagePath;
|
||||||
Vector2 _startPosition;
|
Vector2 _startPosition;
|
||||||
|
|
||||||
|
/// Duration or speed needs to be defined
|
||||||
MoveEffect({
|
MoveEffect({
|
||||||
@required this.path,
|
@required this.path,
|
||||||
double duration,
|
double duration,
|
||||||
@ -34,7 +35,7 @@ class MoveEffect extends SimplePositionComponentEffect {
|
|||||||
bool isRelative = false,
|
bool isRelative = false,
|
||||||
void Function() onComplete,
|
void Function() onComplete,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
duration != null || speed != null,
|
(duration != null) ^ (speed != null),
|
||||||
"Either speed or duration necessary",
|
"Either speed or duration necessary",
|
||||||
),
|
),
|
||||||
super(
|
super(
|
||||||
@ -109,19 +110,16 @@ class MoveEffect extends SimplePositionComponentEffect {
|
|||||||
@override
|
@override
|
||||||
void update(double dt) {
|
void update(double dt) {
|
||||||
super.update(dt);
|
super.update(dt);
|
||||||
if (!hasFinished()) {
|
_currentSubPath ??= _percentagePath.first;
|
||||||
_currentSubPath ??= _percentagePath.first;
|
if (!curveDirection.isNegative && _currentSubPath.endAt < curveProgress ||
|
||||||
if (!curveDirection.isNegative && _currentSubPath.endAt < curveProgress ||
|
curveDirection.isNegative && _currentSubPath.startAt > curveProgress) {
|
||||||
curveDirection.isNegative &&
|
_currentSubPath =
|
||||||
_currentSubPath.startAt > curveProgress) {
|
_percentagePath.firstWhere((v) => v.endAt >= curveProgress);
|
||||||
_currentSubPath =
|
|
||||||
_percentagePath.firstWhere((v) => v.endAt >= curveProgress);
|
|
||||||
}
|
|
||||||
final double lastEndAt = _currentSubPath.startAt;
|
|
||||||
final double localPercentage =
|
|
||||||
(curveProgress - lastEndAt) / (_currentSubPath.endAt - lastEndAt);
|
|
||||||
component.position = _currentSubPath.previous +
|
|
||||||
((_currentSubPath.v - _currentSubPath.previous) * localPercentage);
|
|
||||||
}
|
}
|
||||||
|
final double lastEndAt = _currentSubPath.startAt;
|
||||||
|
final double localPercentage =
|
||||||
|
(curveProgress - lastEndAt) / (_currentSubPath.endAt - lastEndAt);
|
||||||
|
component.position = _currentSubPath.previous +
|
||||||
|
((_currentSubPath.v - _currentSubPath.previous) * localPercentage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ class RotateEffect extends SimplePositionComponentEffect {
|
|||||||
double _startAngle;
|
double _startAngle;
|
||||||
double _delta;
|
double _delta;
|
||||||
|
|
||||||
|
/// Duration or speed needs to be defined
|
||||||
RotateEffect({
|
RotateEffect({
|
||||||
@required this.angle, // As many radians as you want to rotate
|
@required this.angle, // As many radians as you want to rotate
|
||||||
double duration, // How long it should take for completion
|
double duration, // How long it should take for completion
|
||||||
@ -18,7 +19,7 @@ class RotateEffect extends SimplePositionComponentEffect {
|
|||||||
bool isRelative = false,
|
bool isRelative = false,
|
||||||
void Function() onComplete,
|
void Function() onComplete,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
duration != null || speed != null,
|
(duration != null) ^ (speed != null),
|
||||||
"Either speed or duration necessary",
|
"Either speed or duration necessary",
|
||||||
),
|
),
|
||||||
super(
|
super(
|
||||||
@ -47,8 +48,6 @@ class RotateEffect extends SimplePositionComponentEffect {
|
|||||||
@override
|
@override
|
||||||
void update(double dt) {
|
void update(double dt) {
|
||||||
super.update(dt);
|
super.update(dt);
|
||||||
if (!hasFinished()) {
|
component.angle = _startAngle + _delta * curveProgress;
|
||||||
component.angle = _startAngle + _delta * curveProgress;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ class ScaleEffect extends SimplePositionComponentEffect {
|
|||||||
Vector2 _startSize;
|
Vector2 _startSize;
|
||||||
Vector2 _delta;
|
Vector2 _delta;
|
||||||
|
|
||||||
|
/// Duration or speed needs to be defined
|
||||||
ScaleEffect({
|
ScaleEffect({
|
||||||
@required this.size,
|
@required this.size,
|
||||||
double duration, // How long it should take for completion
|
double duration, // How long it should take for completion
|
||||||
@ -48,8 +49,6 @@ class ScaleEffect extends SimplePositionComponentEffect {
|
|||||||
@override
|
@override
|
||||||
void update(double dt) {
|
void update(double dt) {
|
||||||
super.update(dt);
|
super.update(dt);
|
||||||
if (!hasFinished()) {
|
component.size = _startSize + _delta * curveProgress;
|
||||||
component.size = _startSize + _delta * curveProgress;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,24 +27,30 @@ class SequenceEffect extends PositionComponentEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initialize(PositionComponent _comp) {
|
void initialize(PositionComponent component) {
|
||||||
super.initialize(_comp);
|
super.initialize(component);
|
||||||
_currentIndex = 0;
|
_currentIndex = 0;
|
||||||
_driftModifier = 0.0;
|
_driftModifier = 0.0;
|
||||||
|
|
||||||
effects.forEach((effect) {
|
effects.forEach((effect) {
|
||||||
effect.reset();
|
effect.reset();
|
||||||
_comp.size = endSize;
|
component.position = endPosition;
|
||||||
_comp.position = endPosition;
|
component.angle = endAngle;
|
||||||
_comp.angle = endAngle;
|
component.size = endSize;
|
||||||
effect.initialize(_comp);
|
effect.initialize(component);
|
||||||
endSize = effect.endSize;
|
|
||||||
endPosition = effect.endPosition;
|
endPosition = effect.endPosition;
|
||||||
endAngle = effect.endAngle;
|
endAngle = effect.endAngle;
|
||||||
|
endSize = effect.endSize;
|
||||||
});
|
});
|
||||||
peakTime = effects.fold(
|
peakTime = effects.fold(
|
||||||
0,
|
0,
|
||||||
(time, effect) => time + effect.iterationTime,
|
(time, effect) => time + effect.peakTime,
|
||||||
);
|
);
|
||||||
|
if (isAlternating) {
|
||||||
|
endPosition = originalPosition;
|
||||||
|
endAngle = originalAngle;
|
||||||
|
endSize = originalSize;
|
||||||
|
}
|
||||||
component.position = originalPosition;
|
component.position = originalPosition;
|
||||||
component.angle = originalAngle;
|
component.angle = originalAngle;
|
||||||
component.size = originalSize;
|
component.size = originalSize;
|
||||||
@ -54,9 +60,6 @@ class SequenceEffect extends PositionComponentEffect {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void update(double dt) {
|
void update(double dt) {
|
||||||
if (hasFinished()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.update(dt);
|
super.update(dt);
|
||||||
|
|
||||||
// If the last effect's time to completion overshot its total time, add that
|
// If the last effect's time to completion overshot its total time, add that
|
||||||
@ -96,12 +99,10 @@ class SequenceEffect extends PositionComponentEffect {
|
|||||||
@override
|
@override
|
||||||
void reset() {
|
void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
|
component?.position = originalPosition;
|
||||||
|
component?.angle = originalAngle;
|
||||||
|
component?.size = originalSize;
|
||||||
effects.forEach((e) => e.reset());
|
effects.forEach((e) => e.reset());
|
||||||
if (component != null) {
|
initialize(component);
|
||||||
component.position = originalPosition;
|
|
||||||
component.angle = originalAngle;
|
|
||||||
component.size = originalSize;
|
|
||||||
initialize(component);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,16 @@ void effectTest(
|
|||||||
game.update(stepDelta);
|
game.update(stepDelta);
|
||||||
timeLeft -= stepDelta;
|
timeLeft -= stepDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To account for float number operations making effects not finish
|
||||||
|
const double epsilon = 0.000001;
|
||||||
|
if (effect.percentage < epsilon || 1.0 - effect.percentage < epsilon) {
|
||||||
|
game.update(epsilon);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(effect.hasFinished(), shouldFinish, reason: "Effect shouldFinish");
|
||||||
|
expect(callback.isCalled, shouldFinish, reason: "Callback was treated wrong");
|
||||||
|
|
||||||
if (!shouldFinish) {
|
if (!shouldFinish) {
|
||||||
const double floatRange = 0.001;
|
const double floatRange = 0.001;
|
||||||
bool acceptableVector(Vector2 vector, Vector2 expectedVector) {
|
bool acceptableVector(Vector2 vector, Vector2 expectedVector) {
|
||||||
@ -65,7 +75,6 @@ void effectTest(
|
|||||||
"Size is not correct (had: ${component.size} should be: $expectedSize)",
|
"Size is not correct (had: ${component.size} should be: $expectedSize)",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
game.update(0.1);
|
|
||||||
expect(
|
expect(
|
||||||
component.position,
|
component.position,
|
||||||
expectedPosition,
|
expectedPosition,
|
||||||
@ -82,8 +91,6 @@ void effectTest(
|
|||||||
reason: "Size is not exactly correct",
|
reason: "Size is not exactly correct",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
expect(effect.hasFinished(), shouldFinish, reason: "Effect shouldFinish");
|
|
||||||
expect(callback.isCalled, shouldFinish, reason: "Callback was treated wrong");
|
|
||||||
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, shouldFinish);
|
expect(component.effects.isEmpty, shouldFinish);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ void main() {
|
|||||||
final List<Vector2> path = List.generate(3, (i) => randomVector2());
|
final List<Vector2> path = List.generate(3, (i) => randomVector2());
|
||||||
TestComponent component() => TestComponent(position: randomVector2());
|
TestComponent component() => TestComponent(position: randomVector2());
|
||||||
|
|
||||||
MoveEffect effect(bool isInfinite, bool isAlternating) {
|
MoveEffect effect({bool isInfinite = false, bool isAlternating = false}) {
|
||||||
return MoveEffect(
|
return MoveEffect(
|
||||||
path: path,
|
path: path,
|
||||||
duration: 1 + random.nextInt(100).toDouble(),
|
duration: 1 + random.nextInt(100).toDouble(),
|
||||||
@ -26,7 +26,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
component(),
|
component(),
|
||||||
effect(false, false),
|
effect(),
|
||||||
expectedPosition: path.last,
|
expectedPosition: path.last,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -37,7 +37,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
component(),
|
component(),
|
||||||
effect(false, false),
|
effect(),
|
||||||
expectedPosition: path.last,
|
expectedPosition: path.last,
|
||||||
iterations: 1.5,
|
iterations: 1.5,
|
||||||
);
|
);
|
||||||
@ -49,7 +49,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(false, true),
|
effect(isAlternating: true),
|
||||||
expectedPosition: positionComponent.position.clone(),
|
expectedPosition: positionComponent.position.clone(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -61,7 +61,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(true, true),
|
effect(isInfinite: true, isAlternating: true),
|
||||||
expectedPosition: positionComponent.position.clone(),
|
expectedPosition: positionComponent.position.clone(),
|
||||||
iterations: 1.0,
|
iterations: 1.0,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
@ -74,7 +74,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(false, true),
|
effect(isAlternating: true),
|
||||||
expectedPosition: path.last,
|
expectedPosition: path.last,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
iterations: 0.5,
|
iterations: 0.5,
|
||||||
@ -86,7 +86,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(true, false),
|
effect(isInfinite: true),
|
||||||
expectedPosition: path.last,
|
expectedPosition: path.last,
|
||||||
iterations: 3.0,
|
iterations: 3.0,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ void main() {
|
|||||||
const double angleArgument = 6.0;
|
const double angleArgument = 6.0;
|
||||||
TestComponent component() => TestComponent(angle: 0.5);
|
TestComponent component() => TestComponent(angle: 0.5);
|
||||||
|
|
||||||
RotateEffect effect(bool isInfinite, bool isAlternating) {
|
RotateEffect effect({bool isInfinite = false, bool isAlternating = false}) {
|
||||||
return RotateEffect(
|
return RotateEffect(
|
||||||
angle: angleArgument,
|
angle: angleArgument,
|
||||||
duration: 1 + random.nextInt(100).toDouble(),
|
duration: 1 + random.nextInt(100).toDouble(),
|
||||||
@ -21,7 +21,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
component(),
|
component(),
|
||||||
effect(false, false),
|
effect(),
|
||||||
expectedAngle: angleArgument,
|
expectedAngle: angleArgument,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -32,7 +32,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
component(),
|
component(),
|
||||||
effect(false, false),
|
effect(),
|
||||||
expectedAngle: angleArgument,
|
expectedAngle: angleArgument,
|
||||||
iterations: 1.5,
|
iterations: 1.5,
|
||||||
);
|
);
|
||||||
@ -44,7 +44,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(false, true),
|
effect(isAlternating: true),
|
||||||
expectedAngle: positionComponent.angle,
|
expectedAngle: positionComponent.angle,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -56,7 +56,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(true, true),
|
effect(isInfinite: true, isAlternating: true),
|
||||||
expectedAngle: positionComponent.angle,
|
expectedAngle: positionComponent.angle,
|
||||||
iterations: 1.0,
|
iterations: 1.0,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
@ -69,7 +69,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(false, true),
|
effect(isAlternating: true),
|
||||||
expectedAngle: angleArgument,
|
expectedAngle: angleArgument,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
iterations: 0.5,
|
iterations: 0.5,
|
||||||
@ -81,7 +81,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(true, false),
|
effect(isInfinite: true),
|
||||||
expectedAngle: angleArgument,
|
expectedAngle: angleArgument,
|
||||||
iterations: 3.0,
|
iterations: 3.0,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ void main() {
|
|||||||
final Vector2 argumentSize = randomVector2();
|
final Vector2 argumentSize = randomVector2();
|
||||||
TestComponent component() => TestComponent(size: randomVector2());
|
TestComponent component() => TestComponent(size: randomVector2());
|
||||||
|
|
||||||
ScaleEffect effect(bool isInfinite, bool isAlternating) {
|
ScaleEffect effect({bool isInfinite = false, bool isAlternating = false}) {
|
||||||
return ScaleEffect(
|
return ScaleEffect(
|
||||||
size: argumentSize,
|
size: argumentSize,
|
||||||
duration: 1 + random.nextInt(100).toDouble(),
|
duration: 1 + random.nextInt(100).toDouble(),
|
||||||
@ -26,7 +26,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
component(),
|
component(),
|
||||||
effect(false, false),
|
effect(),
|
||||||
expectedSize: argumentSize,
|
expectedSize: argumentSize,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -37,7 +37,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
component(),
|
component(),
|
||||||
effect(false, false),
|
effect(),
|
||||||
expectedSize: argumentSize,
|
expectedSize: argumentSize,
|
||||||
iterations: 1.5,
|
iterations: 1.5,
|
||||||
);
|
);
|
||||||
@ -49,7 +49,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(false, true),
|
effect(isAlternating: true),
|
||||||
expectedSize: positionComponent.size.clone(),
|
expectedSize: positionComponent.size.clone(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -61,7 +61,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(true, true),
|
effect(isInfinite: true, isAlternating: true),
|
||||||
expectedSize: positionComponent.size.clone(),
|
expectedSize: positionComponent.size.clone(),
|
||||||
iterations: 1.0,
|
iterations: 1.0,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
@ -74,7 +74,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(false, true),
|
effect(isAlternating: true),
|
||||||
expectedSize: argumentSize,
|
expectedSize: argumentSize,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
iterations: 0.5,
|
iterations: 0.5,
|
||||||
@ -86,7 +86,7 @@ void main() {
|
|||||||
effectTest(
|
effectTest(
|
||||||
tester,
|
tester,
|
||||||
positionComponent,
|
positionComponent,
|
||||||
effect(true, false),
|
effect(isInfinite: true),
|
||||||
expectedSize: argumentSize,
|
expectedSize: argumentSize,
|
||||||
iterations: 3.0,
|
iterations: 3.0,
|
||||||
shouldFinish: false,
|
shouldFinish: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user