This topic was marked solved by its starter, on May 23rd, 04:08 AM
[BUG] Colour() alpha is not set to GUILabel element when used in constructor

[R3V]Kelvin

  • Jr. Member
  • Posts: 54
[BUG] Colour() alpha is not set to GUILabel element when used in constructor
«  »Last edited
Description
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.

Reproducible
Always.

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

Code: [Select]
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.

Razor.

  • Jr. Member
  • Posts: 96

AdTec_224

  • LU Developer
  • Posts: 30
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:

Code: [Select]
label.Alpha

and:

Code: [Select]
label.Colour

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

Code: [Select]
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:

Code: [Select]
label.TextColour
 

Hope this helps.