HUD Question

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

DJ

New Member
I have drawn my own status display and I want the text to fade in different colors but the text don´t fade, it shows up in white all the time.
What have I done wrong?
I have pasted the code here:

class DJHUD expands ChallengeHUD;

var int X,Y,R,G,B;
var string spread;

function PostRender(canvas C)
{
Super.PostRender(C);
X=0;
Y=C.ClipY/2;
C.SetPos(X, Y);

for(R=0;R<255;R++)
{
if (R==255)
{
R=0;
}
C.DrawColor.R=R;
}
for(G=0;G<255;G++)
{
if (G==255)
{
G=0;
}
C.DrawColor.G=G;
}
for(B=0;B<255;B++)
{
if (B==255)
{
B=0;
}
C.DrawColor.B=B;
}

//C.DrawColor.R = 0;
//C.DrawColor.G = 0;
//C.DrawColor.B = 0;
C.Font = MyFonts.GetBigFont( C.ClipX );
C.DrawText( PlayerOwner.PlayerReplicationInfo.PlayerName, False );
Y=Y+30;
C.SetPos(X,Y);
DrawBigNum(C, PawnOwner.PlayerReplicationInfo.Score, X, Y);
Y=Y+30;
C.SetPos(X,Y);
if (Lead > 0)
Spread = SpreadString$" +"$Lead;
else
Spread = SpreadString$" "$Lead;

C.DrawText(Spread, False);
}
 

doktor_ynohtna

New Member
Jan 15, 2000
11
0
0
Brighton, England
www.ynohtna.org
You've messed up. /~unreal/ubb/html/smile.gif

-----
for(R=0;R<255;R++)
{
if(R==255) {
R=0;
}
C.DrawColor.R=R;
}
-----
This loop runs from zero to 254. It never reachs 255, so the `if' condition is unnecessary. The .R (red) component of the canvas drawcolor is set to the loop variable on each loop.

Note that execution of any other code (such as your instructions to actually render the text onto the canvas) does not occur until the loop has finished with R having a value of 255 and thus failing the loop condition (R < 255). The last set value of C.DrawColor.R is thus 254.

The same is happening with the Green and Red components: you're setting the drawing colours unnecessarily to 0, 1, 2, ... 253, 254 before actually rendering the text with a color of (254, 254, 254) - white.

Try incrementing your R, G, and B variables by 1 on every PostRender call (resetting them to zero when they reach 256), and then drawing the text. You don't need any loops inside the method as the canvas is not actually displayed to the player until the PostRender calls are completed.

Then play around some more until you can figure out how to achieve what you really want to do.

I hope this helps.

Regards,
ynohtnA.