-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
fba5d3b
commit 9d85797
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
source/core/src/main/com/deco2800/game/components/countDownClock/countdownDisplay.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,62 @@ | ||
package com.deco2800.game.components.countdownClock; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.graphics.Color; | ||
import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.scenes.scene2d.ui.*; | ||
import com.deco2800.game.GdxGame; | ||
import com.deco2800.game.ui.UIComponent; | ||
|
||
public class countdownDisplay extends UIComponent { | ||
private final GdxGame game; | ||
private int timeRemaining; | ||
private float timeCount; | ||
public countdownDisplay(GdxGame game) { | ||
super(); | ||
this.game = game; | ||
timeRemaining = 300; | ||
timeCount = 0; | ||
} | ||
Label counterLabel; | ||
|
||
@Override | ||
public void create() { | ||
super.create(); | ||
addActors(); | ||
} | ||
|
||
@Override | ||
public void update() { | ||
super.update(); | ||
timeCount = Gdx.graphics.getDeltaTime(); | ||
if (timeCount >= 1) { | ||
timeRemaining--; | ||
counterLabel.setText(String.valueOf(timeRemaining)); | ||
timeCount = 0; | ||
} | ||
|
||
} | ||
|
||
private void addActors() { | ||
|
||
Label.LabelStyle counterLabelStyle = new Label.LabelStyle(); | ||
// BitmapFont myFont = new BitmapFont(Gdx.files.internal()); | ||
// counterLabelStyle.font = myFont; | ||
counterLabelStyle.fontColor = Color.YELLOW; | ||
|
||
counterLabel = new Label(String.valueOf(timeRemaining), counterLabelStyle); | ||
counterLabel.setPosition((float) (stage.getWidth() * 0.9), (float) (stage.getHeight() * 0.1)); | ||
counterLabel.setSize((float) (stage.getWidth() * 0.05), (float) (stage.getHeight() * 0.03)); | ||
|
||
stage.addActor(counterLabel); | ||
} | ||
|
||
@Override | ||
protected void draw(SpriteBatch batch) { | ||
|
||
} | ||
|
||
|
||
|
||
} |