DrawDFS uses Children
This commit is contained in:
parent
8ec3ef2a58
commit
fb2c9a1474
1 changed files with 12 additions and 7 deletions
|
@ -25,6 +25,8 @@ func init() {
|
|||
type DrawDFS struct {
|
||||
Child interface{}
|
||||
Hides
|
||||
|
||||
game *Game
|
||||
}
|
||||
|
||||
func (d *DrawDFS) Draw(screen *ebiten.Image, opts *ebiten.DrawImageOptions) {
|
||||
|
@ -56,13 +58,16 @@ func (d *DrawDFS) drawRecursive(component interface{}, screen *ebiten.Image, opt
|
|||
return
|
||||
}
|
||||
// Has subcomponents? recurse
|
||||
// TODO: use g.Children or g.Query - but need to go in Scan order...
|
||||
if sc, ok := component.(Scanner); ok {
|
||||
sc.Scan(func(x interface{}) error {
|
||||
// TODO: use g.Query?
|
||||
d.game.Children(component).Scan(func(x interface{}) error {
|
||||
d.drawRecursive(x, screen, opts)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (d *DrawDFS) Prepare(g *Game) error {
|
||||
d.game = g
|
||||
return nil
|
||||
}
|
||||
|
||||
// Scan visits d.Child.
|
||||
|
|
Loading…
Reference in a new issue