mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/hooks: Rename Update -> BeforeUpdate
This commit is contained in:
parent
e085f511ec
commit
1b0e71765f
@ -166,7 +166,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
hooks.AppendHookOnUpdate(func() error {
|
hooks.AppendHookOnBeforeUpdate(func() error {
|
||||||
var err error
|
var err error
|
||||||
theContextLock.Lock()
|
theContextLock.Lock()
|
||||||
if theContext != nil {
|
if theContext != nil {
|
||||||
|
@ -88,7 +88,7 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
|||||||
c.offscreen.fill(0, 0, 0, 0)
|
c.offscreen.fill(0, 0, 0, 0)
|
||||||
|
|
||||||
setRunningSlowly(i < updateCount-1)
|
setRunningSlowly(i < updateCount-1)
|
||||||
if err := hooks.Run(); err != nil {
|
if err := hooks.RunBeforeUpdateHooks(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := c.f(c.offscreen); err != nil {
|
if err := c.f(c.offscreen); err != nil {
|
||||||
|
@ -54,7 +54,7 @@ var theInputState = &inputState{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
hooks.AppendHookOnUpdate(func() error {
|
hooks.AppendHookOnBeforeUpdate(func() error {
|
||||||
theInputState.update()
|
theInputState.update()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -14,16 +14,16 @@
|
|||||||
|
|
||||||
package hooks
|
package hooks
|
||||||
|
|
||||||
var onUpdateHooks = []func() error{}
|
var onBeforeUpdateHooks = []func() error{}
|
||||||
|
|
||||||
// AppendHookOnUpdate appends a hook function that is run before the main update function
|
// AppendHookOnBeforeUpdate appends a hook function that is run before the main update function
|
||||||
// every frame.
|
// every frame.
|
||||||
func AppendHookOnUpdate(f func() error) {
|
func AppendHookOnBeforeUpdate(f func() error) {
|
||||||
onUpdateHooks = append(onUpdateHooks, f)
|
onBeforeUpdateHooks = append(onBeforeUpdateHooks, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run() error {
|
func RunBeforeUpdateHooks() error {
|
||||||
for _, f := range onUpdateHooks {
|
for _, f := range onBeforeUpdateHooks {
|
||||||
if err := f(); err != nil {
|
if err := f(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user