Game Development Reference
In-Depth Information
How it works...
This is very similar to our DrawHealthText() and DrawAmmoText() functions. We add two
functions to allow the text to be displayed. From there we're calling various Canvas functions
to perform activities such as drawing the text, coloring, positioning on screen, and sizing.
Again, we use HudOffset() to align our text with the top of the health bars and on the
center of the screen.
Creating a crosshair
One of the most valuable bits of information in a first person shooter is the crosshair.
This is obviously important for knowing exactly where our shots will land and where
our pawn is focusing its attention.
We're going to be drawing a crosshair directly in the center of the screen, which is precisely
where our projectiles will be firing.
Getting ready
Open your IDE and have the TutorialHUD class ready to edit. We're going to be adding quite
a few variables here.
How to do it...
To create crosshairs we'll need to declare variables which store our data, as well as a function
to draw the actual crosshair. We'll then take our newly created DrawWeaponCrosshair()
function and add it to DrawHUD() , so that it gets drawn on screen with the rest of our HUD.
1.
Let's start by declaring our variables.
/**********************************************************
* Crosshairs
**********************************************************/
/** Used for scaling the size of the crosshair */
var float ConfiguredCrosshairScaling;
/** Coordinates for crosshairs */
var UIRoot.TextureCoordinates CrossHairCoordinates;
 
Search Nedrilad ::




Custom Search