diff --git a/src/cmd/test/main.go b/src/cmd/test/main.go index 7a9fdd4..2ac24f7 100644 --- a/src/cmd/test/main.go +++ b/src/cmd/test/main.go @@ -94,6 +94,8 @@ func (p *Player) Update(e *gx.Engine) error { c.Object.T.RA.Y += gx.Pi * p.MoveSpeed * dt } log.Println(c.Object.T.RA.Y) + case ebiten.Key0 : + e.Del(p) }} return nil diff --git a/src/gx/main.go b/src/gx/main.go index 46ae1a7..56b49f9 100644 --- a/src/gx/main.go +++ b/src/gx/main.go @@ -77,6 +77,21 @@ func (e *Engine) Add(l Layer, b any) { } } +func (e *Engine) Del(b any) { + drawer, ok := b.(Drawer) + if ok { + for layer := range e.layers.Vals() { + layer.V.Del(drawer) + } + } + + behaver, ok := b.(Behaver) + if ok { + e.behavers.Del(behaver) + } + +} + func (e *Engine) AddDrawer(l Layer, d Drawer) { g, ok := e.layers.Get(l) if !ok {