Add ebiten.ScreenScale() (#191)

This commit is contained in:
Hajime Hoshi 2016-03-23 00:44:16 +09:00
parent 2157061479
commit 62dffe5405
4 changed files with 14 additions and 1 deletions

View File

@ -32,7 +32,6 @@ const (
var ( var (
gophersImage *ebiten.Image gophersImage *ebiten.Image
screenScale = initScreenScale
keyStates = map[ebiten.Key]int{ keyStates = map[ebiten.Key]int{
ebiten.KeyUp: 0, ebiten.KeyUp: 0,
ebiten.KeyDown: 0, ebiten.KeyDown: 0,
@ -51,6 +50,7 @@ func update(screen *ebiten.Image) error {
keyStates[key]++ keyStates[key]++
} }
d := 0 d := 0
screenScale := ebiten.ScreenScale()
switch screenScale { switch screenScale {
case 1: case 1:
d = 32 d = 32

View File

@ -97,6 +97,10 @@ func SetScreenScale(scale int) bool {
return currentUI.setScreenSize(currentUI.width, currentUI.height, scale) return currentUI.setScreenSize(currentUI.width, currentUI.height, scale)
} }
func ScreenScale() int {
return currentUI.scale
}
func ActualScale() int { func ActualScale() int {
return currentUI.actualScale() return currentUI.actualScale()
} }

View File

@ -59,6 +59,10 @@ func SetScreenScale(scale int) bool {
return currentUI.setScreenSize(width, height, scale) return currentUI.setScreenSize(width, height, scale)
} }
func ScreenScale() int {
return canvas.Get("dataset").Get("ebitenScale").Int()
}
func ActualScale() int { func ActualScale() int {
return canvas.Get("dataset").Get("ebitenActualScale").Int() return canvas.Get("dataset").Get("ebitenActualScale").Int()
} }

5
run.go
View File

@ -165,3 +165,8 @@ func SetScreenScale(scale int) {
} }
runContext.newScreenScale = scale runContext.newScreenScale = scale
} }
// ScreenScale returns the current screen scale.
func ScreenScale() int {
return ui.ScreenScale()
}