これは本当に簡単な作業ですが、多くの人が未だに根本的な間違いを犯します。 GLES2 ではTextのクラスは二つ以上なく(GLES1では、静的テキスト用の Text クラスと動的テキスト用のChangeableText クラスがありました)、一つだけです - Text クラスで静的テキストと動的テキスト (テキストを更新できる)を両方使用できます。
How to create Text properly.:This is really easy task, but many people still commits a fundamental mistake, in GLES2 we don't have two classes any more (In GLES1, we had Text for static text and ChangeableText for dynamic texts) So we have only one class - Text connecting both functions, static and dynamic text (ability to update text) |
Text t = new Text(0, 0, font, "Score:0123456789", vbo);
なぜそれがとても重要なのか?例えばtext のパラメータとして"Score:"のみを設定して、その後text を "Score: 128" などの新しい値に更新する場合、 プレイヤーはtext更新のタイミングでスローダウンが発生したと感じるでしょう。 上記の例では、使用するであろう文字全てのメモリを'確保'しているので、スローダウンのような問題は発生しません。
1. Most important things while creating text.Always prepare 'memory' while initializing your text objects. Let's say we want to create text responsible for displaying score. Firstly think what kind of characters you will need, in our example only those: "Score:0123456789" So here's example of our newly initialized Text:Text t = new Text(0, 0, font, "Score:0123456789", vbo); Why its so important? If for example we would use as text parameter only "Score:" and than we would update text with new one, for example "Score: 128" player would notice glitch / slow down. In example above, we 'prepared' memory for every char we will use, so there won't be any problems with slow downs and anything else. |
注意事項
|