mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-04 04:47:13 +08:00
melhorias joystick
This commit is contained in:
@ -55,7 +55,7 @@ class JoystickAction {
|
|||||||
}) {
|
}) {
|
||||||
_spriteAction = sprite;
|
_spriteAction = sprite;
|
||||||
_sizeBackgroundDirection = sizeFactorBackgroundDirection * size;
|
_sizeBackgroundDirection = sizeFactorBackgroundDirection * size;
|
||||||
_tileSize = _sizeBackgroundDirection / 3;
|
_tileSize = _sizeBackgroundDirection / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize(Size _screenSize, JoystickController joystickController) {
|
void initialize(Size _screenSize, JoystickController joystickController) {
|
||||||
|
|||||||
@ -9,8 +9,6 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../position.dart';
|
import '../../position.dart';
|
||||||
|
|
||||||
class JoystickDirectional {
|
class JoystickDirectional {
|
||||||
static const double _backgroundAspectRatio = 2.2;
|
|
||||||
|
|
||||||
final double size;
|
final double size;
|
||||||
final Sprite spriteBackgroundDirectional;
|
final Sprite spriteBackgroundDirectional;
|
||||||
final Sprite spriteKnobDirectional;
|
final Sprite spriteKnobDirectional;
|
||||||
@ -64,7 +62,7 @@ class JoystickDirectional {
|
|||||||
..style = PaintingStyle.fill;
|
..style = PaintingStyle.fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
_tileSize = (size / 2) * _backgroundAspectRatio / 3;
|
_tileSize = size / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize(Size _screenSize, JoystickController joystickController) {
|
void initialize(Size _screenSize, JoystickController joystickController) {
|
||||||
@ -133,8 +131,10 @@ class JoystickDirectional {
|
|||||||
final double nextY = dist * sin(_radAngle);
|
final double nextY = dist * sin(_radAngle);
|
||||||
final Offset nextPoint = Offset(nextX, nextY);
|
final Offset nextPoint = Offset(nextX, nextY);
|
||||||
|
|
||||||
final Offset diff = Offset(_backgroundRect.center.dx + nextPoint.dx,
|
final Offset diff = Offset(
|
||||||
_backgroundRect.center.dy + nextPoint.dy) -
|
_backgroundRect.center.dx + nextPoint.dx,
|
||||||
|
_backgroundRect.center.dy + nextPoint.dy,
|
||||||
|
) -
|
||||||
_knobRect.center;
|
_knobRect.center;
|
||||||
_knobRect = _knobRect.shift(diff);
|
_knobRect = _knobRect.shift(diff);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user