Implementing deleting objects.
This commit is contained in:
parent
dd704c9820
commit
1e2e43ad2b
2 changed files with 17 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue