diff --git a/examples/windowsize/main.go b/examples/windowsize/main.go index c7a7a6206..dd773f47e 100644 --- a/examples/windowsize/main.go +++ b/examples/windowsize/main.go @@ -32,7 +32,6 @@ const ( var ( gophersImage *ebiten.Image - screenScale = initScreenScale keyStates = map[ebiten.Key]int{ ebiten.KeyUp: 0, ebiten.KeyDown: 0, @@ -51,6 +50,7 @@ func update(screen *ebiten.Image) error { keyStates[key]++ } d := 0 + screenScale := ebiten.ScreenScale() switch screenScale { case 1: d = 32 diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 5a2764c12..45474dc79 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -97,6 +97,10 @@ func SetScreenScale(scale int) bool { return currentUI.setScreenSize(currentUI.width, currentUI.height, scale) } +func ScreenScale() int { + return currentUI.scale +} + func ActualScale() int { return currentUI.actualScale() } diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 48a13689d..6b4f22650 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -59,6 +59,10 @@ func SetScreenScale(scale int) bool { return currentUI.setScreenSize(width, height, scale) } +func ScreenScale() int { + return canvas.Get("dataset").Get("ebitenScale").Int() +} + func ActualScale() int { return canvas.Get("dataset").Get("ebitenActualScale").Int() } diff --git a/run.go b/run.go index 891175fe3..962f1d0a0 100644 --- a/run.go +++ b/run.go @@ -165,3 +165,8 @@ func SetScreenScale(scale int) { } runContext.newScreenScale = scale } + +// ScreenScale returns the current screen scale. +func ScreenScale() int { + return ui.ScreenScale() +}