forked from AlmasB/FXGLGames
-
Notifications
You must be signed in to change notification settings - Fork 0
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
94 additions
and
1 deletion.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
TowerDefense/src/main/java/com/almasb/fxglgames/td/CurrencyService.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,29 @@ | ||
package com.almasb.fxglgames.td; | ||
|
||
import com.almasb.fxgl.core.EngineService; | ||
import com.almasb.fxgl.core.collection.PropertyMap; | ||
import javafx.beans.property.IntegerProperty; | ||
|
||
/** | ||
* @author Almas Baimagambetov (almaslvl@gmail.com) | ||
*/ | ||
public class CurrencyService extends EngineService { | ||
|
||
private PropertyMap map = new PropertyMap(); | ||
|
||
public CurrencyService() { | ||
map.setValue("currency", 0); | ||
} | ||
|
||
public int getCurrency() { | ||
return map.getInt("currency"); | ||
} | ||
|
||
public void setCurrency(int value) { | ||
map.setValue("currency", value); | ||
} | ||
|
||
public IntegerProperty currencyProperty() { | ||
return map.intProperty("currency"); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
TowerDefense/src/main/java/com/almasb/fxglgames/td/ui/CurrencyIcon.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,24 @@ | ||
package com.almasb.fxglgames.td.ui; | ||
|
||
import javafx.scene.Parent; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Circle; | ||
|
||
/** | ||
* @author Almas Baimagambetov (almaslvl@gmail.com) | ||
*/ | ||
public class CurrencyIcon extends Parent { | ||
|
||
public CurrencyIcon() { | ||
var circleOuter = new Circle(20, Color.YELLOW); | ||
circleOuter.setStroke(Color.BLACK); | ||
circleOuter.setStrokeWidth(4.0); | ||
|
||
var circleInner = new Circle(11, Color.YELLOW.brighter()); | ||
circleInner.setStroke(Color.BLACK); | ||
circleInner.setStrokeWidth(2.0); | ||
circleInner.setTranslateY(-4); | ||
|
||
getChildren().addAll(circleOuter, circleInner); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
TowerDefense/src/main/java/com/almasb/fxglgames/td/ui/CurrencyView.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,33 @@ | ||
package com.almasb.fxglgames.td.ui; | ||
|
||
import com.almasb.fxgl.dsl.FXGL; | ||
import com.almasb.fxglgames.td.CurrencyService; | ||
import javafx.scene.Parent; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Rectangle; | ||
|
||
/** | ||
* @author Almas Baimagambetov (almaslvl@gmail.com) | ||
*/ | ||
public class CurrencyView extends Parent { | ||
|
||
public CurrencyView() { | ||
var bg = new Rectangle(100, 34, Color.color(0.5, 0.5, 0.5, 0.75)); | ||
bg.setStroke(Color.color(0, 0, 0, 0.9)); | ||
bg.setStrokeWidth(2.5); | ||
bg.setArcWidth(10); | ||
bg.setArcHeight(10); | ||
|
||
var icon = new CurrencyIcon(); | ||
icon.setTranslateX(15); | ||
icon.setTranslateY(bg.getHeight() / 2.0); | ||
|
||
var text = FXGL.getUIFactoryService().newText("", Color.WHITE, 22.0); | ||
text.setTranslateX(55); | ||
text.setTranslateY(25); | ||
|
||
text.textProperty().bind(FXGL.getService(CurrencyService.class).currencyProperty().asString()); | ||
|
||
getChildren().addAll(bg, icon, text); | ||
} | ||
} |
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