mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
ebiten: Ensure that Layout is called before Update in the first frame
This commit is contained in:
parent
8003000976
commit
ce24640da8
2
run.go
2
run.go
@ -50,6 +50,8 @@ type Game interface {
|
|||||||
//
|
//
|
||||||
// Layout is called almost every frame.
|
// Layout is called almost every frame.
|
||||||
//
|
//
|
||||||
|
// It is ensured that Layout is invoked before Update is called in the first frame.
|
||||||
|
//
|
||||||
// If Layout returns non-positive numbers, the caller can panic.
|
// 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
|
// You can return a fixed screen size if you don't care, or you can also return a calculated screen size
|
||||||
|
@ -155,6 +155,8 @@ func (c *uiContext) Update() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *uiContext) update() error {
|
func (c *uiContext) update() error {
|
||||||
|
c.updateOffscreen()
|
||||||
|
|
||||||
updateCount := clock.Update(MaxTPS())
|
updateCount := clock.Update(MaxTPS())
|
||||||
|
|
||||||
// Ensure that Update is called once before Draw so that Update can be used for initialization.
|
// Ensure that Update is called once before Draw so that Update can be used for initialization.
|
||||||
@ -174,8 +176,6 @@ func (c *uiContext) update() error {
|
|||||||
uiDriver().ResetForFrame()
|
uiDriver().ResetForFrame()
|
||||||
}
|
}
|
||||||
|
|
||||||
c.updateOffscreen()
|
|
||||||
|
|
||||||
if updateCount > 0 {
|
if updateCount > 0 {
|
||||||
if IsScreenClearedEveryFrame() {
|
if IsScreenClearedEveryFrame() {
|
||||||
c.offscreen.Clear()
|
c.offscreen.Clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user