GLOBAL COMMANDS
Include
"HUDinclude.bb"
Essential command to include the HUD code. Should appear right at the
top of your own code.
CreateHUD (camera)
Creates a HUD object, attaches it to the camera passed to it, and returns
the HUD object of type HUD. Makes the current HUD this HUD.
Example
of use:
myHUD.HUD = CreateHUD(cam)
CreateHUDlayer
(myHUD.HUD [,z_order[,drawlayer]])
Creates a Layer object, attaches it to the passed HUD object, and returns
a Layer object of type HUDlayer. You can optionally specify a z order
which defaults to -99.
If you want to draw with the primitive
commands to a layer then you can optionally specify that it be a drawlayer.
Examples
of use:
myLayer.HUDlayer = CreateHUDlayer(myHUD)
myDrawLayer.HUDlayer = CreateHUDlayer(myHUD,-99,True)
HUDsetLayer
(myLayer.HUDlayer)
Sets
the current layer to use.
HUDlayerCLS
(myLayer.HUDlayer)
Clears the specified layer of all visual information, much like the normal
CLS command does.
HUDClearAll
Clears all HUD related media and data from memory.
FONT COMMANDS
HUDloadFont (font_image$)
Function that loads a bitmap font as created in FONText and returns a
font object of type HUDfont.
HUDfreeFont
myfont.HUDfont
Clears
the specified HUD font from memory.
FontColor font, r,g,b
[,alpha#]
Changes the color of the specified HUD font to the specified colors and
optional alpha. Color values are between 0-255, whereas alpha is between
0-1.
ScaleFont font, x_scale#,
y_scale#
Scale
the specified HUD font by the specified absolute amount.
HUDsetFont font.HUDfont
Set
the current font.
TEXT COMMANDS
HUDtext
x#,y#,txt$
[,justify[,center_y[,space#[,spacemesh]]]]
x,y - position of the text
text$ - text to be displayed
justify - justify text: 0=left, 1=center, 2=right (default: 0)
center_y - true/false to center the text on the y axis (default: false)
space - character spacing multiplier (default: 1)
spacemesh - create mesh quad where spaces occur (used for UI commands).
Draws some
text to the current Layer object at position x,y. Text is drawn to a virtual
screen with a resolution of 800 by 600.
Example
of use:
HUDtext 5,55, "Hello World"
NewHUDcounter (x#,y#,txt$[,just][,cent_y][,space#])
x,y
- position of counter
txt$ - text to be displayed in counter
just - justify text: 0=left, 1=center, 2=right (default: 2)
cent_y - centering on the y axis (default: false)
space - character spacing multiplier (default: 1)
Creates
a Counter object on the current HUD. Counter objects have fixed spacing
between characters and are best used for dynamic text that changes often,
such as the score and life counters. Once created you can change the text
in the Counter object with the UpdateHUDcounter command.
UpdateHUDcounter mycounter.HUDcounter,
txt$
Updates
a Counter object with new text. You should've already created your Counter
object outside of your main loop.
HUDprint txt$
Prints the specified text to the current print layer.
HUDwrite txt$
Writes the specified text to the current print layer.
CreateCharQuad(char$)
Creates a quad mesh (4 vertices, 2 polys) and textures it with a particular
letter. The function returns the handle to the mesh. This is useful for
ABC particles, animated text, etc. Please note that this isn't the most
efficient method for static text: use the HUDtext() command instead.
HUDtextCurve
txt$,x,y,x2,y2,x3,y3, myLayer.HUDlayer [,StartWidth[,MidWidth[,EndWidth]]]
txt - text to display
x,y - position of curve start
x2,y2 - position of curve control point
x3,y3 - position of curve end
myLayer - HUD layer to display the text on
StartWidth = optional width (recommended tho) - default is 1.0
MidWidth - optional
EndWidth - optional
Displays text along a curved line.
IMAGE COMMANDS
HUDdrawImage texture,
x#,y# [,z_order]
Draws the specified texture to the current HUD at the specified position.
You can optionally set a z order for the image using the z_order parameter
- which defaults to -99.
HUDscaleImage myImage.HUDimage,x_scale#,y_scale#
Scales the specified HUD image to the specified absolute scale.
HUDfreeImage myimage.HUDimage
Clears the specified image from the HUD. It also free's the texture from
memory.
'PRIMITIVE' DRAWING COMMANDS
HUDplot x,y, myLayer.HUDlayer
[,width[,height]]
Plots a point at the specified position. Replaces the normal Plot/WritePixel
commands. Use sparingly.
HUDrect x,y, width,height,
myLayer.HUDlayer
Draws a rectangle at the specified position. Replaces the normal Rect
command.
HUDline x,y,x2,y2, myLayer.HUDlayer
[,width[,char$]]
Draws a line at the specified position. Replaces the normal Line command.
You can also specify a thickness and a character to texture the line/rectangle
with. (To use a character you must draw the line to a layer associated
with a font and not a 'draw' type layer.)
HUDcurve x0,y0,x1,y1,cpx,cpy,l.HUDlayer[,width#]
Draws a curved line starting at x0,y0 and ending at x1,y1. The control
point for the curve is at cpx,cpy. The width of the line can be set with
the width parameter (default is 1.0).
USER INTERFACE COMMANDS
MakeImageButton(hi.HUDimage)
Make this
HUDimage clickable. Once activated with this function the image will trigger
a HUDevent() when clicked. Returns the handle for the UI object. You will
need this to compare with the HUDevent().
MakeTextButton(MyLayer.HUDlayer)
Make this
HUDlayer clickable. Once activated with this command the layer will trigger
a HUDevent() when clicked. Returns the handle for the UI object. You will
need this to compare with the HUDevent().
HUDevent()
Use this
function to check for any UI events. It will return the latest UI object
if an event was triggered. You may want to re-write the (or create your
own) HUDevent() function to match the specifics of your user interface.
|