mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 11:43:19 +08:00
👌 Use Offset type directly in JoystickAction.update calculations (#631)
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
## [next]
|
## [next]
|
||||||
|
- Use `Offset` type directly in `JoystickAction.update` calculations
|
||||||
- Changed `parseAnchor` in `examples/widgets` to throw an exception instead of returning null when it cannot parse an anchor name
|
- Changed `parseAnchor` in `examples/widgets` to throw an exception instead of returning null when it cannot parse an anchor name
|
||||||
- Code improvements and preparing APIs to null-safety
|
- Code improvements and preparing APIs to null-safety
|
||||||
- BaseComponent removes children marked as shouldRemove during update
|
- BaseComponent removes children marked as shouldRemove during update
|
||||||
|
|||||||
@ -136,15 +136,11 @@ class JoystickAction {
|
|||||||
// Calculate the knob position
|
// Calculate the knob position
|
||||||
final double nextX = dist * cos(_radAngle);
|
final double nextX = dist * cos(_radAngle);
|
||||||
final double nextY = dist * sin(_radAngle);
|
final double nextY = dist * sin(_radAngle);
|
||||||
final Offset nextPoint = Offset(nextX, nextY);
|
final nextPoint = Offset(nextX, nextY);
|
||||||
|
|
||||||
if (_rectAction != null) {
|
if (_rectAction != null) {
|
||||||
final Offset diff = Offset(
|
final diff =
|
||||||
_rectBackgroundDirection.center.dx + nextPoint.dx,
|
_rectBackgroundDirection.center + nextPoint - _rectAction.center;
|
||||||
_rectBackgroundDirection.center.dy + nextPoint.dy,
|
|
||||||
) -
|
|
||||||
_rectAction.center;
|
|
||||||
|
|
||||||
_rectAction = _rectAction.shift(diff);
|
_rectAction = _rectAction.shift(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user