func newProgressBar() *progressBar { p := &progressBar{ id: len(progressBars), } p.bar = ui.NewImage(render.GetTexture("solid"), 0, 21*float64(p.id), 854, 21, 0, 0, 1, 1, 0, 125, 0) ui.AddDrawable(p.bar.Attach(ui.Top, ui.Left)) p.text = ui.NewText("", 1, 21*float64(p.id)+1, 255, 255, 255) ui.AddDrawable(p.text.Attach(ui.Top, ui.Left)) progressBars = append(progressBars, p) p.bar.SetLayer(-241) p.text.SetLayer(-240) return p }
// AddDrawable adds the drawable to the draw list. func (t *Type) AddDrawable(d ui.Drawable) { t.drawables = append(t.drawables, d) if t.visible { ui.AddDrawable(d) } d.SetRemoveHook(t.removeHook) }
// Show shows all the drawables in the scene func (t *Type) Show() { if t.visible { return } t.visible = true for _, d := range t.drawables { ui.AddDrawable(d) } }