diff --git a/src/Settings.hx b/src/Settings.hx index 9e67e7de..41fb9008 100644 --- a/src/Settings.hx +++ b/src/Settings.hx @@ -86,6 +86,7 @@ typedef TouchSettings = { var rewindButtonSize:Float; var buttonJoystickMultiplier:Float; var hideControls:Bool; + var dynamicJoystick:Bool; var cameraSwipeExtent:Float; } @@ -178,6 +179,7 @@ class Settings { rewindButtonSize: 60, buttonJoystickMultiplier: 2.5, hideControls: false, + dynamicJoystick: false, cameraSwipeExtent: 10.0 } @@ -409,6 +411,9 @@ class Settings { if (touchSettings.cameraSwipeExtent == null) { touchSettings.cameraSwipeExtent = 10.0; } + if (touchSettings.dynamicJoystick == null) { + touchSettings.dynamicJoystick = false; + } #end if (touchSettings.cameraSwipeExtent == 0) { touchSettings.cameraSwipeExtent = 10.0; @@ -531,6 +536,11 @@ class Settings { Settings.optionsSettings.screenWidth / Settings.optionsSettings.screenHeight); } + #if js + MarbleGame.canvas.onResize(MarbleGame.canvas.scene2d.width, MarbleGame.canvas.scene2d.height); + #end + // Console.log('Window resized to ${wnd.width} x ${wnd.height}, scene ${scene2d.width} x ${scene2d.height}'); + MarbleGame.canvas.render(MarbleGame.canvas.scene2d); }); } diff --git a/src/touch/CameraInput.hx b/src/touch/CameraInput.hx index ec97215b..9efda915 100644 --- a/src/touch/CameraInput.hx +++ b/src/touch/CameraInput.hx @@ -51,6 +51,10 @@ 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); + } return; } diff --git a/src/touch/MovementInput.hx b/src/touch/MovementInput.hx index 38bd39c8..a78acffb 100644 --- a/src/touch/MovementInput.hx +++ b/src/touch/MovementInput.hx @@ -103,6 +103,12 @@ class MovementInput { this.joystick.graphics.alpha = 1; } + public function moveToFinger(e:hxd.Event) { + var size = Settings.touchSettings.joystickSize; + this.area.graphics.setPosition(e.relX - size * 3, e.relY - size * 3); + this.collider.onPush(e); + } + public function add(parentGui:GuiControl) { parentGui.addChild(this.area); added = true;