Package com.mygdx.auber.Powerups
Class PowerUp
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.TextureRegion
-
- com.badlogic.gdx.graphics.g2d.Sprite
-
- com.mygdx.auber.Powerups.PowerUp
-
- Direct Known Subclasses:
ArrestUp,FreezeUp,HighlightUp,ShieldUp,SpeedUp
public abstract class PowerUp extends com.badlogic.gdx.graphics.g2d.Sprite
-
-
Constructor Summary
Constructors Constructor Description PowerUp(com.badlogic.gdx.math.Vector2 newPosition)Constructor used to instantiate the class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.badlogic.gdx.math.Vector2getPosition()Returns the player's position.booleanisTaken()Returns if the player has picked up this PowerUp.booleanisUsed()Used to determine if the powerup has been used and is no longer affecting the player.booleanplayerCollision(float playerX, float playerY, float playerWidth, float playerHeight)Determines if the player is touching this powerup.voidrender(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer)Draws this powerup using the specified shapeRenderer.voidsetPosition(com.badlogic.gdx.math.Vector2 newPosition)Sets the position of this PowerUp.voidsetRGB(float newR, float newG, float newB)Sets the colour of this PowerUp.voidsetTaken(boolean newTaken)Sets whether the player has picked up this PowerUp.voidsetUsed(boolean newUsed)Returns whether the player has finished using this PowerUp.abstract voidupdate(Player player)An abstract method used to update the PowerUp every frame.-
Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite
draw, draw, flip, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getWidth, getX, getY, rotate, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
-
Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion
getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
-
-
-
-
Method Detail
-
update
public abstract void update(Player player)
An abstract method used to update the PowerUp every frame.- Parameters:
player- The Player, used to update the PowerUp.
-
playerCollision
public boolean playerCollision(float playerX, float playerY, float playerWidth, float playerHeight)Determines if the player is touching this powerup.- Parameters:
playerX- The x-coordinate of the player.playerY- The y-coordinate of the player.playerWidth- The width of the player.playerHeight- The height of the player.- Returns:
- True if the player is touching this, false otherwise
-
render
public void render(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer)
Draws this powerup using the specified shapeRenderer.- Parameters:
shapeRenderer- The ShapeRenderer used to draw the powerup.
-
isUsed
public boolean isUsed()
Used to determine if the powerup has been used and is no longer affecting the player.- Returns:
- A boolean containing true if the powerup has been used and is no longer affecting the player, false otherwise.
-
setRGB
public void setRGB(float newR, float newG, float newB)Sets the colour of this PowerUp.- Parameters:
newR- The red component of the new colour.newG- The green component of the new colour.newB- The blue component of the new colour.
-
setTaken
public void setTaken(boolean newTaken)
Sets whether the player has picked up this PowerUp.- Parameters:
newTaken- Whether the player has picked up this PowerUp or not.
-
isTaken
public boolean isTaken()
Returns if the player has picked up this PowerUp.- Returns:
- A boolean containing True if the player picked up this PowerUp, false otherwise.
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()
Returns the player's position.- Returns:
- A Vector2 containing the player's position.
-
setUsed
public void setUsed(boolean newUsed)
Returns whether the player has finished using this PowerUp.- Parameters:
newUsed- A boolean containing True if the player has finished using this PowerUp, false otherwise.
-
setPosition
public void setPosition(com.badlogic.gdx.math.Vector2 newPosition)
Sets the position of this PowerUp.- Parameters:
newPosition- A Vector2 containing this PowerUp's new position.
-
-