mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
remove: addCanvas
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package org.toop.app.canvas;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import org.toop.app.App;
|
||||
import org.toop.game.Game;
|
||||
import org.toop.game.tictactoe.TicTacToe;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class TicTacToeCanvas extends GameCanvas {
|
||||
private final TicTacToe game;
|
||||
|
||||
public TicTacToeCanvas() {
|
||||
super(App.getHeight(), App.getHeight(), 3, 3, 10);
|
||||
public TicTacToeCanvas(int width, int height) {
|
||||
super(width, height, 3, 3, 10);
|
||||
game = new TicTacToe();
|
||||
|
||||
graphics.setFill(Color.CYAN);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.toop.app.layer;
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.canvas.GameCanvas;
|
||||
import org.toop.framework.asset.ResourceManager;
|
||||
import org.toop.framework.asset.resources.CssAsset;
|
||||
|
||||
@@ -53,30 +52,6 @@ public abstract class Layer {
|
||||
layer.getChildren().addLast(container.getContainer());
|
||||
}
|
||||
|
||||
protected void addCanvas(GameCanvas canvas, Pos position, int xOffset, int yOffset, int widthPercent, int heightPercent) {
|
||||
StackPane.setAlignment(canvas.getCanvas(), position);
|
||||
|
||||
final double widthUnit = App.getWidth() / 100.0;
|
||||
final double heightUnit = App.getHeight() / 100.0;
|
||||
|
||||
if (widthPercent > 0) {
|
||||
canvas.getCanvas().setWidth(widthPercent * widthUnit);
|
||||
} else {
|
||||
canvas.getCanvas().setWidth(Region.USE_PREF_SIZE);
|
||||
}
|
||||
|
||||
if (heightPercent > 0) {
|
||||
canvas.getCanvas().setHeight(heightPercent * heightUnit);
|
||||
} else {
|
||||
canvas.getCanvas().setHeight(Region.USE_PREF_SIZE);
|
||||
}
|
||||
|
||||
canvas.getCanvas().setTranslateX(xOffset * widthUnit);
|
||||
canvas.getCanvas().setTranslateY(yOffset * heightUnit);
|
||||
|
||||
layer.getChildren().addLast(canvas.getCanvas());
|
||||
}
|
||||
|
||||
protected void pop() {
|
||||
if (layer.getChildren().size() <= 1) {
|
||||
return;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.toop.app.layer.layers;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.canvas.TicTacToeCanvas;
|
||||
import org.toop.app.layer.Container;
|
||||
import org.toop.app.layer.Layer;
|
||||
import org.toop.app.layer.containers.VerticalContainer;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
public class GameLayer extends Layer {
|
||||
public GameLayer() {
|
||||
super("game.css");
|
||||
@@ -23,7 +23,6 @@ public class GameLayer extends Layer {
|
||||
App.activate(new MainLayer());
|
||||
});
|
||||
|
||||
addCanvas(new TicTacToeCanvas(), Pos.CENTER, 0, 0, 100, 100);
|
||||
addContainer(controlContainer, Pos.BOTTOM_LEFT, 2, -2, 0, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user