From a1dd6f3b55ea359787b49c21622a5a01d1242b13 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Tue, 9 Aug 2022 21:03:13 +0530 Subject: [PATCH] touch controls but its platform dependent --- src/MarbleGame.hx | 4 +++- src/MarbleWorld.hx | 12 +++++++++--- src/gui/GuiTextInput.hx | 2 ++ src/gui/PlayGui.hx | 5 ++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 16bdb41d..c803c143 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -136,7 +136,9 @@ class MarbleGame { world = null; return; } - touchInput.update(); + if (Util.isTouchDevice()) { + touchInput.update(); + } if (!paused) { world.update(dt); } diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index c687182d..8cb988b4 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -1011,9 +1011,13 @@ class MarbleWorld extends Scheduler { var pointercontainer = js.Browser.document.querySelector("#pointercontainer"); pointercontainer.hidden = false; #end - MarbleGame.instance.touchInput.setControlsEnabled(false); + if (Util.isTouchDevice()) { + MarbleGame.instance.touchInput.setControlsEnabled(false); + } egg = new EndGameGui((sender) -> { - MarbleGame.instance.touchInput.hideControls(@:privateAccess this.playGui.playGuiCtrl); + if (Util.isTouchDevice()) { + MarbleGame.instance.touchInput.hideControls(@:privateAccess this.playGui.playGuiCtrl); + } this.dispose(); var pmg = new PlayMissionGui(); PlayMissionGui.currentSelectionStatic = mission.index + 1; @@ -1028,7 +1032,9 @@ class MarbleWorld extends Scheduler { #if js pointercontainer.hidden = true; #end - MarbleGame.instance.touchInput.setControlsEnabled(true); + if (Util.isTouchDevice()) { + MarbleGame.instance.touchInput.setControlsEnabled(true); + } // @:privateAccess playGui.playGuiCtrl.render(scene2d); }, mission, finishTime); MarbleGame.canvas.pushDialog(egg); diff --git a/src/gui/GuiTextInput.hx b/src/gui/GuiTextInput.hx index ac4fc6ed..be233436 100644 --- a/src/gui/GuiTextInput.hx +++ b/src/gui/GuiTextInput.hx @@ -60,6 +60,8 @@ class GuiTextInput extends GuiControl { #if js if (Util.isTouchDevice()) { text.text = js.Browser.window.prompt("Enter your name", text.text); + var canvas = js.Browser.document.querySelector("#webgl"); + canvas.focus(); js.Browser.document.documentElement.requestFullscreen(); } #end diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index 5ae447a9..a597fc6d 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -27,6 +27,7 @@ import src.Resource; import hxd.res.Sound; import h3d.mat.Texture; import src.Settings; +import src.Util; class PlayGui { var scene2d:h2d.Scene; @@ -130,7 +131,9 @@ class PlayGui { initPowerupBox(); initTexts(); - MarbleGame.instance.touchInput.showControls(this.playGuiCtrl); + if (Util.isTouchDevice()) { + MarbleGame.instance.touchInput.showControls(this.playGuiCtrl); + } playGuiCtrl.render(scene2d);