You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-16Lines changed: 26 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
BGText is a [Blender Game Engine](https://en.wikipedia.org/wiki/Blender_Game_Engine) and [UPBGE](https://upbge.org/) utility aiming to enhance the experience with text objects.
5
5
6
6
Motivations
7
-
=========
7
+
===========
8
8
9
9
In the old days of BGE there was a feature known as bitmap text. It allowed you to setup a font texture to a plane, map its UV to a single character, enable the Text option on its material, add an Text property to the object and then show a text based on the property, pretty complicated. Then, it was replaced by the dynamic text, now based on True Type fonts, where you add a text, a property named Text to it and then show a text based on this property.
10
10
@@ -29,32 +29,43 @@ Obs: UPBGE fixed the resolution issues on dynamic texts, allowing you to change
29
29
I've used dynamic texts over a long time due to its ease, and I know some people that still uses the bitmap text due to the ability to stylize the text with outlines and other stuff. Based on this, I thought to work in some way to overcome those issues.
30
30
31
31
BGText's Features
32
-
==============
32
+
=================
33
33
34
34
BGText tries to mix the pros and fix most of the cons on bitmap texts and dynamic texts, also providing an easy interface to setup each feature (by using game properties). The main features are:
35
35
36
36
- Easy to use, but also complex if you need.
37
37
- Text styles based on textures, so it's highly customizable.
38
-
- Character size based on its absolute center.
38
+
- Character size based on each character origin.
39
39
- Horizontal and vertical character offset (distance between characters).
40
40
- Automatic text wrap based on number of characters per line.
41
41
- Left, center and right text alignment (justify).
42
42
- Literal text or Python expressions (a huge time saver!).
43
43
- Color based on predefined color names or RGBA vectors.
44
44
- Static text or updated by an specified interval.
45
+
- Update texts without the need of constant processing with the message `UpdateText`.
46
+
-`UpdateText` messages can update `All` texts or the ones with specific `Id` properties.
45
47
46
-
BGText is compatible with both vanilla BGE and UPBGE. BGText uses a shape key action to switch each character value. This method is not the lightest one, as in UPBGE I could have made each character a single plane, copy its mesh at runtime (possible only in UPBGE) and warp its UV to change the character shown, but it's using the shape key method to keep compatibility between UPBGE and BGE.
48
+
BGText is compatible with both vanilla BGE and UPBGE. BGText uses the replace mesh functionality to switch between characters values.
47
49
48
50
How To Use
49
-
=========
51
+
==========
50
52
51
53
It's simple: on your blend file, link the group BGText from BGText blend file (`File` > `Link`), then you're ready to use it. To setup the text, all you have to do is to add properties to the group instance of BGText, and when you play the game the given properties will be applied.
52
54
53
-
All the characters on BGText instance will automatically be parented to the group object, so you can do whatever logic you want to on top of the instance, even change the text at runtime (see the use of `Update` property below).
55
+
All the characters on BGText instance will automatically be parented to the group object, so you can do whatever logic you want to on top of the instance, even change the text at runtime (see the use of `UpdateText` messages below).
54
56
55
-
Reference
57
+
Messages
56
58
========
57
59
60
+
BGText can trigger specific actions by using messages. To use this functionality, just send a message with a specific subject and you're ready to go.
61
+
62
+
-**Subject:**`UpdateText`
63
+
-**Description:** Updates the text at command without the need of processing the text each frame with the `Update` property.
64
+
-**Body:**`All` to update all texts or an `Id` value to update only texts with this value.
65
+
66
+
Reference
67
+
=========
68
+
58
69
This reference shows which attributes you could use on BGText group instance to change its behavior. You don't need to add all the attributes, only those you want to setup.
59
70
60
71
-`Text`
@@ -86,7 +97,7 @@ This reference shows which attributes you could use on BGText group instance to
86
97
-**Type:**`String`
87
98
88
99
-`Update`
89
-
-**Description:** Updates values constantly (for example, time or life). The value is the number of skipped frames. If value is less than 0, it disables `Update`.
100
+
-**Description:** Updates values constantly (for example, time). The value is the number of skipped frames. If value is less than 0, it disables `Update`.
90
101
-**Type:**`Integer`
91
102
92
103
-`Style`
@@ -97,23 +108,22 @@ This reference shows which attributes you could use on BGText group instance to
97
108
-**Description:** Name of color or vector. Currently supports `red`, `green`, `blue`, `white`, `black`, `yellow`, `purple`, `cyan` (case insensitive) or a tuple or list like `(1, 0.5, 0.1, 1)` representing RGBA values.
98
109
-**Type:**`String`
99
110
111
+
-`Id`
112
+
-**Description:** Identifier of current text. Can be used to update texts with specific identifiers with `UpdateText` messages.
113
+
-**Type:**`String`
114
+
100
115
Known Issues
101
-
===========
116
+
============
102
117
103
118
There's some issues I noticed when using BGText, so they are on the list to be fixed or amenized on the future.
When updating a text very fast (like a timer), a flickering can be noticed. It happens due to all characters are removed to add new ones, and this takes more processing time than it should. In the future, I plan to make only characters that need to be replaced to do so. So, for example, in a timer with miliseconds, the miliseconds characters will change constantly and the seconds will only be replaced when it needs to, instead of being replaced along with the miliseconds ones (as it currently is).
109
-
110
120
Script performance is not optimal
111
121
--------------------------------------------
112
122
113
-
For portability reasons, I chose to use the Script mode on Python controller instead of Module mode. This fixes some script import issues and gives freedom for the developer to put BGText blend file wherever it wants to, but it comes with a price. As the Script mode makes the script be parsed at runtime, it's much slower than the module Mode, and this can be a serious issue when using lots of BGText instances with the `Update`attribute (which was already mentioned to be problematic). I don't plan to change the controller mode for the already mentioned reasons, but the `bgtext.py` script is already in a module format, so if the performance becomes a serious issue to you, you could only change the entry points on the Python controllers of BGText blend file to fit your needs.
123
+
For portability reasons, I chose to use the Script mode on Python controller instead of Module mode. This fixes some script import issues and gives freedom for the developer to put BGText blend file wherever it wants to, but it comes with a price. As the Script mode makes the script be parsed at runtime, it's much slower than the module Mode, and this can be a serious issue when using lots of BGText instances with the `Update`property. I don't plan to change the controller mode for the already mentioned reasons, but the `bgtext.py` script is already in a module format, so if the performance becomes a serious issue to you, you could only change the entry points on the Python controllers of BGText blend file to fit your needs. The comments on the last lines of the `bgtext.py` will explain what to do.
114
124
115
125
Extras
116
-
=====
126
+
======
117
127
118
128
Along with the default font style textures, BGText comes with some image overlays for you to design your own font style textures. They are at the `source` directory, and comes with a single overlay (`TextStyleOverlay.png`) or multiple overlays (directory `TextStyleOverlay`). Those are useful when you're working with a image editor that supports layers.
0 commit comments