MCPcopy Index your code
hub / github.com/EngoEngine/engo / New

Method New

demos/textbox/textbox.go:72–106  ·  view source on GitHub ↗
(w *ecs.World)

Source from the content-addressed store, hash-verified

70}
71
72func (t *TypingSystem) New(w *ecs.World) {
73 fnt := &common.Font{
74 URL: "Roboto-Regular.ttf",
75 FG: color.Black,
76 Size: 64,
77 }
78 err := fnt.CreatePreloaded()
79 if err != nil {
80 panic(err)
81 }
82
83 t.label = MyLabel{BasicEntity: ecs.NewBasic()}
84 t.label.SpaceComponent.Position.Set(0, 75)
85 t.label.RenderComponent.Drawable = common.Text{
86 Font: fnt,
87 Text: "",
88 }
89
90 for _, system := range w.Systems() {
91 switch sys := system.(type) {
92 case *common.RenderSystem:
93 sys.Add(&t.label.BasicEntity, &t.label.RenderComponent, &t.label.SpaceComponent)
94 }
95 }
96
97 engo.Mailbox.Listen("TextMessage", func(msg engo.Message) {
98 m, ok := msg.(engo.TextMessage)
99 if !ok {
100 return
101 }
102 t.runeLock.Lock()
103 t.runesToAdd = append(t.runesToAdd, m.Char)
104 t.runeLock.Unlock()
105 })
106}
107
108func (*TypingSystem) Remove(ecs.BasicEntity) {}
109

Callers

nothing calls this directly

Calls 4

CreatePreloadedMethod · 0.95
ListenMethod · 0.80
SetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected