UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 7

191

/** Texture for HP bar*/
var const Texture2D BarTexture;

/** Current owner of the HUD */
var Pawn PawnOwner;

/** Sets owner of the current TutorialPawn */
var TutorialPawn TutPawnOwner;

/** Positoning for HP bar and text */
var vector2D HPPosition, HPTextOffset;
var TextureCoordinates BarCoords;


  1. Next we need the PostRender() function, which is responsible for caching the
    value of our variables, and is part of the main draw loop.
    /**

    • Caches values for variables. Also the main draw loop
      **/
      event PostRender()
      {
      Super.PostRender();




/** Sets the pawn owner */
PawnOwner = Pawn(PlayerOwner.ViewTarget);
if ( PawnOwner == None )
{
PawnOwner = PlayerOwner.Pawn;
}
TutPawnOwner = TutorialPawn(PawnOwner);

if (TutPawnOwner != None)
{
/** Sets the size of the screen based on resolution*/
ResScaleX = Canvas.ClipX/1024;
ResScaleY = Canvas.ClipY/768;
}
}

We won't use PostRender as heavily as Unreal Tournament does, but it is important
to understand that it's essential for using Scaleform as it allows for additional things
to be drawn on screen, including animated crosshairs and overlays that mobile
devices, such as iOS, require.
Free download pdf