MCPcopy
hub / github.com/EngoEngine/engo / Setup

Method Setup

demos/text/text.go:37–79  ·  view source on GitHub ↗

Setup is called before the main loop is started

(u engo.Updater)

Source from the content-addressed store, hash-verified

35
36// Setup is called before the main loop is started
37func (*DefaultScene) Setup(u engo.Updater) {
38 w, _ := u.(*ecs.World)
39
40 common.SetBackground(color.White)
41 w.AddSystem(&common.RenderSystem{})
42
43 // Adding KeyboardScroller so we can actually see the difference between the HUD and non-HUD text
44 w.AddSystem(common.NewKeyboardScroller(scrollSpeed, engo.DefaultHorizontalAxis, engo.DefaultVerticalAxis))
45 w.AddSystem(&common.MouseZoomer{zoomSpeed})
46
47 fnt := &common.Font{
48 URL: "Roboto-Regular.ttf",
49 FG: color.Black,
50 Size: 64,
51 }
52 err := fnt.CreatePreloaded()
53 if err != nil {
54 panic(err)
55 }
56
57 label1 := MyLabel{BasicEntity: ecs.NewBasic()}
58 label1.RenderComponent.Drawable = common.Text{
59 Font: fnt,
60 Text: "Hello world !",
61 }
62 label1.SetShader(common.HUDShader)
63
64 label2 := MyLabel{BasicEntity: ecs.NewBasic()}
65 label2.RenderComponent.Drawable = common.Text{
66 Font: fnt,
67 Text: "This may also be text\nwhich includes a newline. ",
68 LineSpacing: 0.5,
69 LetterSpacing: 0.15,
70 }
71
72 for _, system := range w.Systems() {
73 switch sys := system.(type) {
74 case *common.RenderSystem:
75 sys.Add(&label1.BasicEntity, &label1.RenderComponent, &label1.SpaceComponent)
76 sys.Add(&label2.BasicEntity, &label2.RenderComponent, &label2.SpaceComponent)
77 }
78 }
79}
80
81func (*DefaultScene) Type() string { return "Game" }
82

Callers

nothing calls this directly

Calls 5

CreatePreloadedMethod · 0.95
SetBackgroundFunction · 0.92
NewKeyboardScrollerFunction · 0.92
SetShaderMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected