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; ...@@ -14,6 +14,8 @@ import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler;
import de.hdm_stuttgart.battlearena.Model.Map.TileManager; import de.hdm_stuttgart.battlearena.Model.Map.TileManager;
import javafx.animation.AnimationTimer; import javafx.animation.AnimationTimer;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.geometry.Insets; import javafx.geometry.Insets;
...@@ -119,22 +121,18 @@ public class GameSceneController implements Initializable { ...@@ -119,22 +121,18 @@ public class GameSceneController implements Initializable {
enemyHealth.setWidth(healthBarWidth); enemyHealth.setWidth(healthBarWidth);
// make it responsive // make it responsive
if (ScreenClasses.inRange((int) diagonalInches) == ScreenClasses.INCH27) { stackPane.heightProperty().addListener((observableValue, oldValue, newValue) -> {
canvas2D.setScaleX(1.5); canvas2D.setScaleY(newValue.doubleValue() / 870);
canvas2D.setScaleY(1.5); canvas2D.setScaleX(newValue.doubleValue() / 870);
} else if (ScreenClasses.inRange((int) diagonalInches) == ScreenClasses.INCH13_SURFACE) { });
// TODO: make a enum for MacBook screens
} else { System.out.println(stackPane.heightProperty());
canvas2D.setScaleX(0.87);
canvas2D.setScaleY(0.87);
playerHealth.setHeight(50);
enemyHealth.setHeight(50);
BorderPane.setMargin(stackPane, new Insets(-40, 0, 0, 0));
}
System.out.println("dpi: " + screen.getDpi()); System.out.println("dpi: " + screen.getDpi());
// testing hp bar // testing hp bar
slider.valueProperty().addListener((observableValue, oldValue, newValue) -> { slider.valueProperty().addListener((observableValue, oldValue, newValue) -> {
System.out.println(stackPane.widthProperty().doubleValue());
System.out.println(stackPane.heightProperty().doubleValue());
double newWidth = healthBarWidth * (newValue.doubleValue() / 100); double newWidth = healthBarWidth * (newValue.doubleValue() / 100);
playerHealth.setWidth(newWidth); playerHealth.setWidth(newWidth);
playerHp.setText(newValue.intValue() + "%"); 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