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

Method New

common/fps.go:29–67  ·  view source on GitHub ↗

New is called when FPSSystem is added to the world

(w *ecs.World)

Source from the content-addressed store, hash-verified

27
28// New is called when FPSSystem is added to the world
29func (f *FPSSystem) New(w *ecs.World) {
30 if f.Display {
31 if f.Font == nil {
32 if err := engo.Files.LoadReaderData("gomonobold_fps.ttf", bytes.NewReader(gomonobold.TTF)); err != nil {
33 panic("unable to load gomonobold.ttf for the fps system! Error was: " + err.Error())
34 }
35
36 f.Font = &Font{
37 URL: "gomonobold_fps.ttf",
38 FG: color.White,
39 BG: color.Black,
40 Size: 32,
41 }
42
43 if err := f.Font.CreatePreloaded(); err != nil {
44 panic("unable to create gomonobold.ttf for the fps system! Error was: " + err.Error())
45 }
46 }
47
48 txt := Text{
49 Font: f.Font,
50 Text: f.DisplayString(),
51 }
52 b := ecs.NewBasic()
53 f.entity.BasicEntity = &b
54 f.entity.RenderComponent = &RenderComponent{
55 Drawable: txt,
56 }
57 f.entity.RenderComponent.SetShader(HUDShader)
58 f.entity.RenderComponent.SetZIndex(1000)
59 f.entity.SpaceComponent = &SpaceComponent{}
60 for _, system := range w.Systems() {
61 switch sys := system.(type) {
62 case *RenderSystem:
63 sys.Add(f.entity.BasicEntity, f.entity.RenderComponent, f.entity.SpaceComponent)
64 }
65 }
66 }
67}
68
69// Add doesn't do anything since New creates the only entity used
70func (*FPSSystem) Add() {}

Callers 15

openFileFunction · 0.45
registerGamepadImplMethod · 0.45
rafPolyfillFunction · 0.45
openFileFunction · 0.45
SetSceneFunction · 0.45
registerGamepadImplMethod · 0.45
registerGamepadImplMethod · 0.45
TestTMXFiletypeLoadFunction · 0.45
TestTMXGridFunction · 0.45

Calls 7

DisplayStringMethod · 0.95
LoadReaderDataMethod · 0.80
CreatePreloadedMethod · 0.80
SetShaderMethod · 0.80
SetZIndexMethod · 0.80
ErrorMethod · 0.45
AddMethod · 0.45