Game Development Reference
In-Depth Information
Creating the rocket bullet UI
Here we are at the last secion of this chapter. As we know from the last step, we need a
way to show the number of rockets left on the screen. In this step, we will create the rocket
UI, which will show the number of rockets left and the rocket graphics. We will use both
GUITexture
and
OnGUI()
to create the UI.
Engage Thrusters
This is the last secion, which will create the
RocketUI
script to display the remaining rocket
bullets on the screen:
1. Go to
Assets
|
Create
|
Javascript
and name it
RocketUI
. Then, double-click on it
to open
MonoDevelop
and replace the script as follows:
public var rocketLauncher : RocketLauncher;
public var customSkin : GUISkin;
public var width : float = 80;
public var height : float = 25;
public var pixelShift : int = 2;
public function OnGUI() : void {
GUI.skin = customSkin;
DrawShadowText(new Rect(Screen.width*transform.position.x,
(Screen.height*(1.0 - (transform.position.y - 0.005))), width,
height), rocketLauncher.ammoCount.ToString(), customSkin.
GetStyle("RocketText"), Color.white);