|
4 | 4 | Uses
|
5 | 5 | {$IFDEF DEBUG_LEAKS}MemCheck,{$ELSE} TERRA_MemoryManager,{$ENDIF}
|
6 | 6 | TERRA_String, TERRA_Utils, TERRA_Application, TERRA_Scene, TERRA_Client, TERRA_UI, TERRA_GraphicsManager,
|
7 |
| - TERRA_ResourceManager, TERRA_Color, TERRA_Font, TERRA_OS, TERRA_FileManager, |
8 |
| - TERRA_PNG, TERRA_TTF, TERRA_Viewport, TERRA_SpriteManager, TERRA_Localization; |
| 7 | + TERRA_ResourceManager, TERRA_Color, TERRA_Font, TERRA_FontRenderer, TERRA_OS, TERRA_FileManager, |
| 8 | + TERRA_PNG, TERRA_TTF, TERRA_Viewport, TERRA_SpriteManager, TERRA_Localization, |
| 9 | + TERRA_InputManager; |
9 | 10 |
|
10 | 11 | Type
|
11 | 12 | // A client is used to process application events
|
|
24 | 25 | End;
|
25 | 26 |
|
26 | 27 | Var
|
27 |
| - _Font:Font = Nil; |
| 28 | + _FontRenderer:FontRenderer = Nil; |
28 | 29 |
|
29 | 30 | { Game }
|
30 | 31 | Procedure MyGame.OnCreate;
|
|
35 | 36 | GraphicsManager.Instance.ActiveViewport.BackgroundColor := ColorRed;
|
36 | 37 |
|
37 | 38 | // Load a font
|
38 |
| - _Font := FontManager.Instance.GetFont('droid'); |
| 39 | + _FontRenderer := FontRenderer.Create(); |
| 40 | + _FontRenderer.SetFont(FontManager.Instance.GetFont('droid')); |
39 | 41 |
|
40 | 42 | // Create a scene and set it as the current scene
|
41 | 43 | _Scene := MyScene.Create;
|
|
45 | 47 | // OnIdle is called once per frame, put your game logic here
|
46 | 48 | Procedure MyGame.OnDestroy;
|
47 | 49 | Begin
|
| 50 | + ReleaseObject(_FontRenderer); |
48 | 51 | ReleaseObject(_Scene);
|
49 | 52 | End;
|
50 | 53 |
|
51 | 54 | Procedure MyGame.OnIdle;
|
52 | 55 | Begin
|
53 |
| - If Keys.WasReleased(keyEscape) Then |
| 56 | + If InputManager.Instance.Keys.WasReleased(keyEscape) Then |
54 | 57 | Application.Instance.Terminate;
|
55 | 58 | End;
|
56 | 59 |
|
|
72 | 75 | Procedure MyScene.RenderSprites(V:Viewport);
|
73 | 76 | Begin
|
74 | 77 | // render some text
|
75 |
| - If Assigned(_Font) Then |
| 78 | + If Assigned(_FontRenderer.Font) Then |
76 | 79 | Begin
|
77 |
| - _Font.DrawText(50, 70, 10, ' Hello World!', ColorWhite, 1.0, True); |
78 |
| - _Font.DrawText(200, 160, 10, 'This is a'+StringFromChar(fontControlNewLine)+'line break!', ColorYellow, 1.0, True); |
| 80 | + _FontRenderer.DrawText(50, 70, 10, ' Hello World!'); |
79 | 81 |
|
80 |
| - _Font.DrawText(200, 100, 10, StringFromChar(fontControlWave)+'Wavy text!', ColorBlue, 1.0, True); |
| 82 | + _FontRenderer.SetColor(ColorYellow); |
| 83 | + _FontRenderer.DrawText(200, 160, 10, 'This is a'+StringFromChar(fontControlNewLine)+'line break!'); |
81 | 84 |
|
82 |
| - _Font.DrawText(400, 100, 10, StringFromChar(fontControlItalics)+' Italic text!', ColorGreen, 1.0, True); |
| 85 | + _FontRenderer.SetColor(ColorBlue); |
| 86 | + _FontRenderer.DrawText(200, 100, 10, StringFromChar(fontControlWave)+'Wavy text!'); |
| 87 | + |
| 88 | + _FontRenderer.SetColor(ColorGreen); |
| 89 | + _FontRenderer.DrawText(400, 100, 10, StringFromChar(fontControlItalics)+' Italic text!'); |
83 | 90 |
|
84 | 91 | // unicode rendering
|
85 |
| - _Font.DrawText(50, 200, 10, GetLanguageDescription(language_Russian), ColorWhite, 1.0, True); |
86 |
| - _Font.DrawText(50, 230, 10, GetLanguageDescription(language_Chinese), ColorWhite, 1.0, True); |
87 |
| - _Font.DrawText(50, 260, 10, GetLanguageDescription(language_Korean), ColorWhite, 1.0, True); |
88 |
| - _Font.DrawText(50, 290, 10, GetLanguageDescription(language_Japanese), ColorWhite, 1.0, True); |
| 92 | + _FontRenderer.SetColor(ColorWhite); |
| 93 | + _FontRenderer.DrawText(50, 200, 10, GetLanguageDescription(language_Russian)); |
| 94 | + _FontRenderer.DrawText(50, 230, 10, GetLanguageDescription(language_Chinese)); |
| 95 | + _FontRenderer.DrawText(50, 260, 10, GetLanguageDescription(language_Korean)); |
| 96 | + _FontRenderer.DrawText(50, 290, 10, GetLanguageDescription(language_Japanese)); |
89 | 97 | End;
|
90 | 98 | End;
|
91 | 99 |
|
|
0 commit comments