12-27-2010, 17:05
(This post was last modified: 12-27-2010, 17:15 by alistair3149.)
This tutorial is originally wrote by kiwimoosical for MW2, but progress bar is working in BO as same as MW2, so I quoted his tutorial to here
Step 1: Declare your progress bar:
Step 2: Create your progress bar's color:
First you need to get the RGB of your color and divide it by 255, then you put it where i say:
Step 3: Fill the bar:
Step 4: Reposition maybeh? Here:
Step 5: Text pl0x:
Step 5a: Create the text element:
Step 5b: text reposition?
Step 5c: Setting the text:
Step 6: Updating your progress bar:
To Destroy the bar:
Here is an example of Health Bar:
Here's another example, but it is an ammo bar (credit to 4fun)
Step 1: Declare your progress bar:
Code:
b = createPrimaryProgressBar( 45 ); //the number is the initial y position
Step 2: Create your progress bar's color:
First you need to get the RGB of your color and divide it by 255, then you put it where i say:
Code:
b.bar.color = (0,1,1); //Mine is cyan
Step 3: Fill the bar:
Code:
b updateBar(1); //1 is the highest it can go, updateBar is also used for changing the bar's filled level
Step 4: Reposition maybeh? Here:
Code:
b.bar.x = 100; // This is the main coord you want, find it first
b.x = 160; // Add 60 to the previous coord to get it so the bar and color align
b.bar.y = 10; // Find coord for y axis
b.y = 10; // Make this the same as the above choice
Step 5: Text pl0x:
Step 5a: Create the text element:
Code:
t = createPrimaryProgressBarText( 25 );
Step 5b: text reposition?
Code:
t.x = 160; // Same as b.x
t.y = 20; // Add 10 for below the bar and subtract 10 for above the bar (subtract from b.y)
Step 5c: Setting the text:
Code:
t setText("Test");
Step 6: Updating your progress bar:
Code:
b updateBar(.5); //Take the percent of the bar you want filled and divide it by 100 to get the percent
To Destroy the bar:
Code:
barName destroyElem();
Here is an example of Health Bar:
Code:
HealthBar()
{
useBar = createPrimaryProgressBar( -250 );
useBarText = createPrimaryProgressBarText( -250 );
useBarText settext("Health");
useBarText.y = 205;
useBar.bar.y = 220;
useBar.y = 220;
for(;;)
{
usebar updateBar( self.health/100, 100 );
if(self.health < 50 && self.health < 30 != true)
{
usebar.color = (0,0,0);
usebar.bar.color = (0.9,1,0);
useBarText settext("^3Injuried");
usebar.alpha = 0.5;
}
else if(self.health < 30)
{
usebar.color = (0,0,0);
usebar.bar.color = (1,0,0);
useBarText settext("^1Critical");
usebar.alpha = 1;
}
else if(self.health > 50)
{
usebar.color = (0,0,0);
usebar.bar.color = (0,1,0);
useBarText settext("^2Normal");
usebar.alpha = 0.5;
}
wait 0.05;
}
}
Here's another example, but it is an ammo bar (credit to 4fun)