[BUG] Colour() alpha is not set to GUILabel element when used in constructor

Started by Kelvin Garcia Mendoza, May 09, 2021, 10:03 PM

Previous topic - Next topic

Kelvin Garcia Mendoza

Using Colour() within a GUILabel element constructor will fail to set label's alpha. Its alpha will always be initialized at 255. However, if you decide to use label.Colour = Colour( r, g, b, a ); or label.Alpha = alpha; it will just work fine.


What you were doing when the bug happened
Attempting to initialize a GUILabel element with alpha set to 0 using Colour() in its constructor:

label <- null;

function Script::ScriptLoad()
 ::label = ::GUILabel( ::VectorScreen( ::GUI.GetScreenSize().X * 0.48, ::GUI.GetScreenSize().Y * 0.51 ), ::Colour( 255, 255, 255, 0 ), "Hello there." );

What you think caused the bug
No idea. This bug seems to be affecting GUILabel elements only.



I think you're misunderstanding what the colour parameter is for. In this case, colour refers to the colour of the text (and by extension text alpha) and not the alpha value of the overall label.

So simply put:


set the alpha (and colour) value of the label itself, whereas the colour parameter in this code:

GUILabel(VectorScreen(0, 0), Colour(255, 255, 255, 0), "Colour!");
sets the colour and alpha of the text only, so it's effectively doing the same as:


Hope this helps.