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() {
|
||||
hooks.AppendHookOnUpdate(func() error {
|
||||
hooks.AppendHookOnBeforeUpdate(func() error {
|
||||
var err error
|
||||
theContextLock.Lock()
|
||||
if theContext != nil {
|
||||
|
@ -88,7 +88,7 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
||||
c.offscreen.fill(0, 0, 0, 0)
|
||||
|
||||
setRunningSlowly(i < updateCount-1)
|
||||
if err := hooks.Run(); err != nil {
|
||||
if err := hooks.RunBeforeUpdateHooks(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.f(c.offscreen); err != nil {
|
||||
|
@ -54,7 +54,7 @@ var theInputState = &inputState{
|
||||
}
|
||||
|
||||
func init() {
|
||||
hooks.AppendHookOnUpdate(func() error {
|
||||
hooks.AppendHookOnBeforeUpdate(func() error {
|
||||
theInputState.update()
|
||||
return nil
|
||||
})
|
||||
|
@ -14,16 +14,16 @@
|
||||
|
||||
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.
|
||||
func AppendHookOnUpdate(f func() error) {
|
||||
onUpdateHooks = append(onUpdateHooks, f)
|
||||
func AppendHookOnBeforeUpdate(f func() error) {
|
||||
onBeforeUpdateHooks = append(onBeforeUpdateHooks, f)
|
||||
}
|
||||
|
||||
func Run() error {
|
||||
for _, f := range onUpdateHooks {
|
||||
func RunBeforeUpdateHooks() error {
|
||||
for _, f := range onBeforeUpdateHooks {
|
||||
if err := f(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user