Moin Leute,
ein neuer Tag eine neue Frage.
Bin gerade dabei eine GUI für ein Brettspiel zu schreiben und arbeite gerade an meiner letzten Scene.
Die Scene soll die aktuelle Position der Spieler anzeigen. Jedes mal wenn gewürfelt wird , soll der Spieler versetzt werden.
Meine FXML ist folgendermaßen aufgebaut.
Ich habe eine Klasse Spieler , in dem die Position des Spielers gespeichert wird.
Wie ist es möglich die Circle (repräsentieren Spieler) nach jedem Wurf zu versetzten?
Ist das Konstrukt von GridPane-Rectange-Circle überhaupt dafür geeignet?
Hatte im ersten Versuch GridPane-Pane-Circle.
Gruß
ein neuer Tag eine neue Frage.
Bin gerade dabei eine GUI für ein Brettspiel zu schreiben und arbeite gerade an meiner letzten Scene.
Die Scene soll die aktuelle Position der Spieler anzeigen. Jedes mal wenn gewürfelt wird , soll der Spieler versetzt werden.
Meine FXML ist folgendermaßen aufgebaut.
Java:
<AnchorPane prefHeight="600.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller">
<children>
<VBox alignment="CENTER" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<HBox alignment="CENTER" prefHeight="520.0" prefWidth="700.0">
<children>
<GridPane alignment="CENTER" gridLinesVisible="true" prefHeight="509.0" prefWidth="702.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Rectangle fx:id="f0" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #c8c8c8;" width="89.0" />
<Rectangle fx:id="f1" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="1" />
<Rectangle fx:id="f2" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="2" />
<Rectangle fx:id="f3" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="3" />
<Rectangle fx:id="f4" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="4" />
<Rectangle fx:id="f5" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="5" />
<Rectangle fx:id="f6" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="6" />
<Rectangle fx:id="f7" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="7" />
<Rectangle fx:id="f8" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="7" GridPane.rowIndex="1" />
<Rectangle fx:id="f9" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="6" GridPane.rowIndex="1" />
<Rectangle fx:id="f10" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="5" GridPane.rowIndex="1" />
<Rectangle fx:id="f11" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="4" GridPane.rowIndex="1" />
<Rectangle fx:id="f12" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="3" GridPane.rowIndex="1" />
<Rectangle fx:id="f13" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Rectangle fx:id="f14" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Rectangle fx:id="f15" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.rowIndex="1" />
<Rectangle fx:id="f16" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.rowIndex="2" />
<Rectangle fx:id="f17" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Rectangle fx:id="f18" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<Rectangle fx:id="f19" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="3" GridPane.rowIndex="2" />
<Rectangle fx:id="f20" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="4" GridPane.rowIndex="2" />
<Rectangle fx:id="f21" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="5" GridPane.rowIndex="2" />
<Rectangle fx:id="f22" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="6" GridPane.rowIndex="2" />
<Rectangle fx:id="f23" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="7" GridPane.rowIndex="2" />
<Rectangle fx:id="f24" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="7" GridPane.rowIndex="3" />
<Rectangle fx:id="f25" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="6" GridPane.rowIndex="3" />
<Rectangle fx:id="f26" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="5" GridPane.rowIndex="3" />
<Rectangle fx:id="f27" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="4" GridPane.rowIndex="3" />
<Rectangle fx:id="f28" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="3" GridPane.rowIndex="3" />
<Rectangle fx:id="f29" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<Rectangle fx:id="f30" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Rectangle fx:id="f31" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.rowIndex="3" />
<Rectangle fx:id="f32" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.rowIndex="4" />
<Rectangle fx:id="f33" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Rectangle fx:id="f34" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<Rectangle fx:id="f35" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="3" GridPane.rowIndex="4" />
<Rectangle fx:id="f36" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="4" GridPane.rowIndex="4" />
<Rectangle fx:id="f37" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="5" GridPane.rowIndex="4" />
<Rectangle fx:id="f38" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="6" GridPane.rowIndex="4" />
<Rectangle fx:id="f39" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="7" GridPane.rowIndex="4" />
<Rectangle fx:id="f40" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="7" GridPane.rowIndex="5" />
<Rectangle fx:id="f41" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="6" GridPane.rowIndex="5" />
<Rectangle fx:id="f42" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="5" GridPane.rowIndex="5" />
<Rectangle fx:id="f43" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="4" GridPane.rowIndex="5" />
<Rectangle fx:id="f44" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="3" GridPane.rowIndex="5" />
<Rectangle fx:id="f45" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<Rectangle fx:id="f46" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Rectangle fx:id="f47" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.rowIndex="5" />
<Rectangle fx:id="f48" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.rowIndex="6" />
<Rectangle fx:id="f49" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<Rectangle fx:id="f50" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="2" GridPane.rowIndex="6" />
<Rectangle fx:id="f51" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="3" GridPane.rowIndex="6" />
<Rectangle fx:id="f52" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="4" GridPane.rowIndex="6" />
<Rectangle fx:id="f53" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="5" GridPane.rowIndex="6" />
<Rectangle fx:id="f54" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="6" GridPane.rowIndex="6" />
<Rectangle fx:id="f55" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="7" GridPane.rowIndex="6" />
<Rectangle fx:id="f56" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="7" GridPane.rowIndex="7" />
<Rectangle fx:id="f57" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="6" GridPane.rowIndex="7" />
<Rectangle fx:id="f58" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #520a00;" width="89.0" GridPane.columnIndex="5" GridPane.rowIndex="7" />
<Rectangle fx:id="f59" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #329f9c;" width="89.0" GridPane.columnIndex="4" GridPane.rowIndex="7" />
<Rectangle fx:id="f60" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="3" GridPane.rowIndex="7" />
<Rectangle fx:id="f61" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="2" GridPane.rowIndex="7" />
<Rectangle fx:id="f62" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #9c68a4;" width="89.0" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<Rectangle fx:id="f63" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="64.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #006400;" width="89.0" GridPane.rowIndex="7" />
<Circle fx:id="BLAU" fill="DODGERBLUE" radius="12.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #1510eb;">
<GridPane.margin>
<Insets left="2.0" top="-35.0" />
</GridPane.margin>
</Circle>
<Circle fx:id="GELB" fill="DODGERBLUE" radius="12.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #fff468;">
<GridPane.margin>
<Insets left="30.0" top="-35.0" />
</GridPane.margin>
</Circle>
<Circle fx:id="ROT" fill="DODGERBLUE" radius="12.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #cd5c5c;">
<GridPane.margin>
<Insets left="60.0" top="-35.0" />
</GridPane.margin>
</Circle>
<Circle fx:id="SCHWARZ" fill="DODGERBLUE" radius="12.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #051403;">
<GridPane.margin>
<Insets left="2.0" top="35.0" />
</GridPane.margin>
</Circle>
<Circle fx:id="GRUEN" fill="DODGERBLUE" radius="12.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #49e76c;">
<GridPane.margin>
<Insets left="30.0" top="35.0" />
</GridPane.margin>
</Circle>
<Circle fx:id="WEISS" fill="DODGERBLUE" radius="12.0" stroke="BLACK" strokeType="INSIDE" style="-fx-fill: #ffffff;">
<GridPane.margin>
<Insets left="60.0" top="35.0" />
</GridPane.margin>
</Circle>
</children>
</GridPane>
</children>
</HBox>
<HBox alignment="CENTER" maxHeight="-Infinity" prefHeight="100.0" prefWidth="200.0" spacing="60.0">
<children>
<Label fx:id="player" onDragDetected="#handlePlayer" text="Spieler">
<font>
<Font name="Lucida Console" size="18.0" />
</font>
</Label>
<Button fx:id="rollDice" disable="false" mnemonicParsing="false" onAction="#handleRollDice" text="roll dice">
<font>
<Font name="Lucida Console" size="15.0" />
</font></Button>
<Label fx:id="actualyField" text="Feld">
<font>
<Font name="Lucida Console" size="18.0" />
</font>
</Label>
</children>
</HBox>
</children>
</VBox>
</children>
</AnchorPane>
Ich habe eine Klasse Spieler , in dem die Position des Spielers gespeichert wird.
Wie ist es möglich die Circle (repräsentieren Spieler) nach jedem Wurf zu versetzten?
Ist das Konstrukt von GridPane-Rectange-Circle überhaupt dafür geeignet?
Hatte im ersten Versuch GridPane-Pane-Circle.
Gruß