fix few touch things

This commit is contained in:
RandomityGuy 2024-06-11 23:43:49 +05:30
parent 1a99b32e55
commit 85ce3b2102
5 changed files with 33 additions and 13 deletions

View file

@ -53,8 +53,16 @@ class Main extends hxd.App {
s2d.scaleMode = Zoom(zoomRatio); s2d.scaleMode = Zoom(zoomRatio);
#end #end
#if android #if android
var zoomRatio = Window.getInstance().height / 700; var zoomRatio = Math.min(Window.getInstance().height, Window.getInstance().width) / 700;
s2d.scaleMode = Zoom(zoomRatio); s2d.scaleMode = Zoom(zoomRatio);
trace("Initial Window resized to "
+ Window.getInstance().width
+ "x"
+ Window.getInstance().height
+ " (Zoom "
+ zoomRatio
+ ")");
#end #end
#if android #if android

View file

@ -237,7 +237,7 @@ class Settings {
return null; return null;
} }
@:hlNative public static function open_url(url:String):Void {} @:hlNative public static function open_web_url(url:String):Void {}
#end #end
public static function applySettings() { public static function applySettings() {
@ -506,9 +506,26 @@ class Settings {
public static function init() { public static function init() {
load(); load();
#if hl #if hl
Window.getInstance().resize(Window.getInstance().width, Window.getInstance().height); var wnd = Window.getInstance();
// var zoomRatio = Window.getInstance().windowToPixelRatio;
// Window.getInstance().resize(Window.getInstance().width, Window.getInstance().height);
// Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight); // Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
Window.getInstance().displayMode = optionsSettings.isFullScreen ? FullscreenResize : Windowed; // Window.getInstance().displayMode = optionsSettings.isFullScreen ? FullscreenResize : Windowed;
var zoomRatio = Math.min(Window.getInstance().height, Window.getInstance().width) / 700;
Settings.zoomRatio = zoomRatio;
#if hl
Settings.optionsSettings.screenWidth = cast wnd.width;
Settings.optionsSettings.screenHeight = cast wnd.height;
#end
trace("Window resized to "
+ Settings.optionsSettings.screenWidth
+ "x"
+ Settings.optionsSettings.screenHeight
+ " (Zoom "
+ zoomRatio
+ ")");
// MarbleGame.canvas.scene2d.scaleMode = Zoom(zoomRatio);
#end #end
#if js #if js
Window.getInstance().propagateKeyEvents = true; Window.getInstance().propagateKeyEvents = true;

View file

@ -163,7 +163,7 @@ class MainMenuGui extends GuiImage {
kofi.extent = new Vector(143, 36); kofi.extent = new Vector(143, 36);
kofi.pressedAction = (sender) -> { kofi.pressedAction = (sender) -> {
#if sys #if sys
Settings.open_url("https://ko-fi.com/H2H5FRTTL"); Settings.open_web_url("https://ko-fi.com/H2H5FRTTL");
#end #end
#if js #if js
js.Browser.window.open("https://ko-fi.com/H2H5FRTTL"); js.Browser.window.open("https://ko-fi.com/H2H5FRTTL");
@ -178,7 +178,7 @@ class MainMenuGui extends GuiImage {
github.extent = new Vector(94, 38); github.extent = new Vector(94, 38);
github.pressedAction = (sender) -> { github.pressedAction = (sender) -> {
#if sys #if sys
Settings.open_url("https://github.com/RandomityGuy/MBHaxe"); Settings.open_web_url("https://github.com/RandomityGuy/MBHaxe");
#end #end
#if js #if js
js.Browser.window.open("https://github.com/RandomityGuy/MBHaxe"); js.Browser.window.open("https://github.com/RandomityGuy/MBHaxe");

View file

@ -1054,7 +1054,7 @@ class PlayMissionGui extends GuiImage {
kofi.extent = new Vector(143, 36); kofi.extent = new Vector(143, 36);
kofi.pressedAction = (sender) -> { kofi.pressedAction = (sender) -> {
#if sys #if sys
Settings.open_url("https://ko-fi.com/H2H5FRTTL"); Settings.open_web_url("https://ko-fi.com/H2H5FRTTL");
#end #end
#if js #if js
js.Browser.window.open("https://ko-fi.com/H2H5FRTTL"); js.Browser.window.open("https://ko-fi.com/H2H5FRTTL");

View file

@ -24,12 +24,7 @@ class TouchOptionsGui extends GuiImage {
this.position = new Vector(); this.position = new Vector();
this.extent = new Vector(640, 480); this.extent = new Vector(640, 480);
#if hl var scene2d = MarbleGame.canvas.scene2d;
var scene2d = hxd.Window.getInstance();
#end
#if js
var scene2d = MarbleGame.instance.scene2d;
#end
var offsetX = (scene2d.width - 1280) / 2; var offsetX = (scene2d.width - 1280) / 2;
var offsetY = (scene2d.height - 720) / 2; var offsetY = (scene2d.height - 720) / 2;