diff --git a/examples/windowsize/main.go b/examples/windowsize/main.go index 7f418583e..33494bf0e 100644 --- a/examples/windowsize/main.go +++ b/examples/windowsize/main.go @@ -148,6 +148,7 @@ func (g *game) Update(screen *ebiten.Image) error { const d = 16 toUpdateWindowSize := false + toUpdateWindowPosition := false if ebiten.IsKeyPressed(ebiten.KeyShift) { if inpututil.IsKeyJustPressed(ebiten.KeyUp) { screenHeight += d @@ -172,15 +173,19 @@ func (g *game) Update(screen *ebiten.Image) error { } else { if inpututil.IsKeyJustPressed(ebiten.KeyUp) { positionY -= d + toUpdateWindowPosition = true } if inpututil.IsKeyJustPressed(ebiten.KeyDown) { positionY += d + toUpdateWindowPosition = true } if inpututil.IsKeyJustPressed(ebiten.KeyLeft) { positionX -= d + toUpdateWindowPosition = true } if inpututil.IsKeyJustPressed(ebiten.KeyRight) { positionX += d + toUpdateWindowPosition = true } } if inpututil.IsKeyJustPressed(ebiten.KeyS) && !*flagAutoAdjusting { @@ -262,7 +267,9 @@ func (g *game) Update(screen *ebiten.Image) error { } ebiten.SetMaxTPS(tps) ebiten.SetWindowDecorated(decorated) - ebiten.SetWindowPosition(positionX, positionY) + if toUpdateWindowPosition { + ebiten.SetWindowPosition(positionX, positionY) + } ebiten.SetWindowFloating(floating) ebiten.SetScreenClearedEveryFrame(screenCleared) if maximize && ebiten.IsWindowResizable() {