-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions
44
source/core/src/main/com/csse3200/game/components/maingame/LevelProgressBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.csse3200.game.components.maingame; | ||
|
||
import com.badlogic.gdx.graphics.Color; | ||
import com.badlogic.gdx.graphics.Pixmap; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar; | ||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; | ||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; | ||
|
||
public class LevelProgressBar extends ProgressBar { | ||
|
||
/** | ||
* @param width of the health bar | ||
* @param height of the health bar | ||
*/ | ||
public LevelProgressBar(int width, int height) { | ||
super(0f, 100f, 0.01f, false, new ProgressBarStyle()); | ||
getStyle().background = getColoredDrawable(width, height, Color.RED); | ||
// getStyle().knob = getColoredDrawable(0, height, Color.GREEN); | ||
getStyle().knob = new TextureRegionDrawable(new TextureRegion(new Texture("images/skeleton.png"))); | ||
getStyle().knobBefore = getColoredDrawable(width, height, Color.GREEN); | ||
|
||
setWidth(width); | ||
setHeight(height); | ||
|
||
setAnimateDuration(0.0f); | ||
setValue(1f); | ||
|
||
setAnimateDuration(0.25f); | ||
} | ||
|
||
public static Drawable getColoredDrawable(int width, int height, Color color) { | ||
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888); | ||
pixmap.setColor(color); | ||
pixmap.fill(); | ||
|
||
TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(pixmap))); | ||
|
||
pixmap.dispose(); | ||
|
||
return drawable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters