Package com.misc
Class ResourceBar
- java.lang.Object
-
- com.misc.ResourceBar
-
public class ResourceBar extends java.lang.ObjectResource bars used by sprites to indicate properties of sprites. These are graphical and displayed to the user.- Since:
- 17/12/2019
-
-
Constructor Summary
Constructors Constructor Description ResourceBar(float spriteWidth, float spriteHeight)Constructor for this class, gathers required information so that it can be drawn.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddResourceAmount(int amount)Add a value to the resource bar.intgetCurrentAmount()Get the current resource amount.floatgetFade()Get the bar's alpha value, manipulated to remain in the range 0-1.floatgetMaxAmount()Get the max resource amount.voidresetResourceAmount()Reset the resource amount back to its original full capacity, this is used for replenishing the fire truck's water after the tutorial has finishedvoidsetColourRange(com.badlogic.gdx.graphics.Color[] colours)Set the colour range of the bar.voidsetCurrentAmount(int amount)Set the current resource amount.voidsetFade(boolean shouldFadeIn, boolean shouldFadeOut)Fade the bar either in or out using it's alpha value.voidsetMaxResource(int maxAmount)Set the maximum limit for the resource bar.voidsetPosition(float spriteXPos, float spriteYPos)Set the position of the bar, takes into account the sprite's dimensionsvoidsubtractResourceAmount(int amount)Subtract a value from the resource bar.voidupdate(com.badlogic.gdx.graphics.g2d.Batch batch)Draw the resource bar.
-
-
-
Method Detail
-
update
public void update(com.badlogic.gdx.graphics.g2d.Batch batch)
Draw the resource bar. Needs to be called every frame.- Parameters:
batch- The batch to draw the resource bar onto.
-
setPosition
public void setPosition(float spriteXPos, float spriteYPos)Set the position of the bar, takes into account the sprite's dimensions- Parameters:
spriteXPos- The x-coordinate of the sprite.spriteYPos- The y-coordinate of the sprite.
-
setFade
public void setFade(boolean shouldFadeIn, boolean shouldFadeOut)Fade the bar either in or out using it's alpha value.- Parameters:
shouldFadeIn- Whether to fade in (true) or out (false)shouldFadeOut- Whether to fade out (true) or out (false)
-
getFade
public float getFade()
Get the bar's alpha value, manipulated to remain in the range 0-1.- Returns:
- The alpha value of the bar
-
setColourRange
public void setColourRange(com.badlogic.gdx.graphics.Color[] colours)
Set the colour range of the bar. The bar is split into 3 sections so 3 colours are required.- Parameters:
colours- The colours the sprite will use;
-
getCurrentAmount
public int getCurrentAmount()
Get the current resource amount.- Returns:
- The current resource amount;
-
setCurrentAmount
public void setCurrentAmount(int amount)
Set the current resource amount.- Parameters:
amount- The amount the current resource amount will be set to;
-
getMaxAmount
public float getMaxAmount()
Get the max resource amount.- Returns:
- The max resource amount;
-
setMaxResource
public void setMaxResource(int maxAmount)
Set the maximum limit for the resource bar.- Parameters:
maxAmount- The maximum limit for the resource bar.
-
addResourceAmount
public void addResourceAmount(int amount)
Add a value to the resource bar.- Parameters:
amount- The value to add to the resource bar.
-
subtractResourceAmount
public void subtractResourceAmount(int amount)
Subtract a value from the resource bar.- Parameters:
amount- The value to subtract from the resource bar.
-
resetResourceAmount
public void resetResourceAmount()
Reset the resource amount back to its original full capacity, this is used for replenishing the fire truck's water after the tutorial has finished
-
-