Skip to content
Snippets Groups Projects
Commit d62b7ead authored by Tran Peter's avatar Tran Peter
Browse files

update(Game Scene): fix responsive layout for canvas #14

parent e9d94b54
No related branches found
No related tags found
5 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!27Player can now place bombs that have a explosion radius that dont go through the wall.,!26Merge game scene into development
......@@ -14,6 +14,8 @@ import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler;
import de.hdm_stuttgart.battlearena.Model.Map.TileManager;
import javafx.animation.AnimationTimer;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
......@@ -119,22 +121,18 @@ public class GameSceneController implements Initializable {
enemyHealth.setWidth(healthBarWidth);
// make it responsive
if (ScreenClasses.inRange((int) diagonalInches) == ScreenClasses.INCH27) {
canvas2D.setScaleX(1.5);
canvas2D.setScaleY(1.5);
} else if (ScreenClasses.inRange((int) diagonalInches) == ScreenClasses.INCH13_SURFACE) {
// TODO: make a enum for MacBook screens
} else {
canvas2D.setScaleX(0.87);
canvas2D.setScaleY(0.87);
playerHealth.setHeight(50);
enemyHealth.setHeight(50);
BorderPane.setMargin(stackPane, new Insets(-40, 0, 0, 0));
}
stackPane.heightProperty().addListener((observableValue, oldValue, newValue) -> {
canvas2D.setScaleY(newValue.doubleValue() / 870);
canvas2D.setScaleX(newValue.doubleValue() / 870);
});
System.out.println(stackPane.heightProperty());
System.out.println("dpi: " + screen.getDpi());
// testing hp bar
slider.valueProperty().addListener((observableValue, oldValue, newValue) -> {
System.out.println(stackPane.widthProperty().doubleValue());
System.out.println(stackPane.heightProperty().doubleValue());
double newWidth = healthBarWidth * (newValue.doubleValue() / 100);
playerHealth.setWidth(newWidth);
playerHp.setText(newValue.intValue() + "%");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment