mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Panic if Layout returns non-positive numbers
This commit is contained in:
parent
049aa552d4
commit
1d9c00688c
4
run.go
4
run.go
@ -36,7 +36,9 @@ type Game interface {
|
||||
//
|
||||
// The screen scale is automatically adjusted to fit the outside.
|
||||
//
|
||||
// Layout is called at an initialization and whenever the outside size is changed.
|
||||
// Layout is called almost every frame.
|
||||
//
|
||||
// If Layout returns non-positive numbers, the caller can panic.
|
||||
//
|
||||
// You can return a fixed screen size if you don't care, or you can also return a calculated screen size
|
||||
// adjusted with the given outside size.
|
||||
|
@ -147,6 +147,9 @@ func (c *uiContext) Layout(outsideWidth, outsideHeight float64) {
|
||||
|
||||
func (c *uiContext) updateOffscreen() {
|
||||
sw, sh := c.game.Layout(int(c.outsideWidth), int(c.outsideHeight))
|
||||
if sw <= 0 || sh <= 0 {
|
||||
panic("ebiten: Layout must return positive numbers")
|
||||
}
|
||||
|
||||
if c.offscreen != nil && !c.outsideSizeUpdated {
|
||||
if w, h := c.offscreen.Size(); w == sw && h == sh {
|
||||
|
Loading…
Reference in New Issue
Block a user