UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Miscellaneous Recipes


240


  1. We need to create the DrawDebugText() function in our TestHUD class which is
    called by DrawDebugMenu() in our DebugScreen class.
    /*****

    • Draws the text for the debug screen
      *****/
      function DrawDebugText(string text, Vector2D position, Font
      font,Color textColor)
      {
      Canvas.SetDrawColorStruct(textColor);
      Canvas.SetPos(position.X,position.Y);
      Canvas.Font = font;
      Canvas.DrawText(text);
      }




This draws the debug text and looks similar to the other canvas functions we used in
Chapter 7, HUD.


  1. Our TutorialHUD class's PostRender() event needs to call our DebugMenu as
    well, so let's do that now.
    event PostRender()
    {
    ....
    /* Draws debug HUD /
    DebugMenu(PlayerOwner.CheatManager).DrawDebugMenu(self);
    ....
    }

  2. The final step in this recipe has us assigning the DebugMenu class as the default
    cheat class in our TutorialPlayerController class. Add the following bit of
    code to the defaultproperties block:
    defaultproperties
    {
    ....
    CheatClass=class'DebugMenu' // Reference for DebugMenu
    ....
    }

Free download pdf