mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-28 02:42:19 +00:00
fix dyn joystick
This commit is contained in:
parent
7fe505c6a8
commit
899a86ba6f
2 changed files with 27 additions and 8 deletions
|
|
@ -49,10 +49,16 @@ class CameraInput {
|
|||
|
||||
var scene2d = interactive.getScene();
|
||||
if (e.relX < scene2d.width / 2) {
|
||||
if (Settings.touchSettings.dynamicJoystick) {
|
||||
// Move that joystick over our finger
|
||||
MarbleGame.instance.touchInput.movementInput.moveToFinger(e);
|
||||
var restartG = @:privateAccess MarbleGame.instance.touchInput.pauseButton?.collider;
|
||||
if (restartG != null) {
|
||||
if (e.relY > restartG.getAbsPos().y + restartG.height) {
|
||||
if (Settings.touchSettings.dynamicJoystick) {
|
||||
// Move that joystick over our finger
|
||||
MarbleGame.instance.touchInput.movementInput.moveToFinger(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import h2d.col.Bounds;
|
|||
import gui.GuiControl;
|
||||
import h3d.Vector;
|
||||
import gui.GuiGraphics;
|
||||
import src.MarbleGame;
|
||||
|
||||
class MovementInput {
|
||||
var area:GuiGraphics;
|
||||
|
|
@ -109,11 +110,23 @@ class MovementInput {
|
|||
}
|
||||
|
||||
public function moveToFinger(e:hxd.Event) {
|
||||
var size = Settings.touchSettings.joystickSize;
|
||||
var scene2d = collider.getScene();
|
||||
this.area.graphics.setPosition(Util.clamp(e.relX - size * 3, 0, scene2d.width / 2 - size * 6),
|
||||
Util.clamp(e.relY - size * 3, 0, scene2d.height - size * 6));
|
||||
this.collider.onPush(e);
|
||||
var restartG = @:privateAccess MarbleGame.instance.touchInput.pauseButton?.collider;
|
||||
if (restartG != null) {
|
||||
var size = Settings.touchSettings.joystickSize;
|
||||
var scene2d = collider.getScene();
|
||||
this.area.graphics.setPosition(Util.clamp(e.relX - size * 3, 0, scene2d.width / 2 - size * 6),
|
||||
Util.clamp(e.relY - size * 3, restartG.getAbsPos().y + restartG.height, scene2d.height - size * 6));
|
||||
|
||||
var xPos = Util.clamp(e.relX - this.area.graphics.x, size, size * 5);
|
||||
var yPos = Util.clamp(e.relY - this.area.graphics.y, size, size * 5);
|
||||
|
||||
this.value.x = (xPos - (size * 3)) / (size * 2);
|
||||
this.value.y = (yPos - (size * 3)) / (size * 2);
|
||||
|
||||
this.joystick.graphics.setPosition(this.area.graphics.x + xPos, this.area.graphics.y + yPos);
|
||||
|
||||
this.collider.onPush(e);
|
||||
}
|
||||
}
|
||||
|
||||
public function add(parentGui:GuiControl) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue