mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-11 18:11:12 +08:00
Ensuring final position and size for MoveEffect and ScaleEffect
This commit is contained in:
@@ -14,7 +14,7 @@ class MyGame extends BaseGame with TapDetector {
|
|||||||
add(square = Square()
|
add(square = Square()
|
||||||
..anchor = Anchor.center
|
..anchor = Anchor.center
|
||||||
..x = 200
|
..x = 200
|
||||||
..y = 400);
|
..y = 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ class ScaleEffect extends PositionComponentEffect {
|
|||||||
|
|
||||||
component.width = _original.width + _diff.width * c * _dir.x;
|
component.width = _original.width + _diff.width * c * _dir.x;
|
||||||
component.height = _original.height + _diff.height * c * _dir.y;
|
component.height = _original.height + _diff.height * c * _dir.y;
|
||||||
|
} else {
|
||||||
|
component.width = size.width;
|
||||||
|
component.height = size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ellapsedTime += dt;
|
_ellapsedTime += dt;
|
||||||
@@ -120,6 +123,9 @@ class MoveEffect extends PositionComponentEffect {
|
|||||||
|
|
||||||
component.x = _xOriginal + _xDistance * c * _xDirection;
|
component.x = _xOriginal + _xDistance * c * _xDirection;
|
||||||
component.y = _yOriginal + _yDistance * c * _yDirection;
|
component.y = _yOriginal + _yDistance * c * _yDirection;
|
||||||
|
} else {
|
||||||
|
component.x = destination.x;
|
||||||
|
component.y = destination.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ellapsedTime += dt;
|
_ellapsedTime += dt;
|
||||||
|
|||||||
Reference in New Issue
Block a user