Solved the fps counter zoom together with canvas problem. Workaround used was changing fps counter on game view to race view.

#story[1117] #pair[ptg19, zyt10]
This commit is contained in:
Zhi You Tan
2017-08-13 18:52:42 +12:00
parent 8ec6490627
commit 0b978593d4
4 changed files with 38 additions and 8 deletions
@@ -174,7 +174,6 @@ public class GameClient {
break; break;
case BOAT_XML: case BOAT_XML:
System.out.println("GOT SUM BOATS YAY :)");
allBoatsMap = XMLParser.parseBoats( allBoatsMap = XMLParser.parseBoats(
StreamParser.extractXmlMessage(packet) StreamParser.extractXmlMessage(packet)
); );
@@ -119,18 +119,14 @@ public class GameView extends Pane {
this.setLayoutX(0); this.setLayoutX(0);
this.setLayoutY(0); this.setLayoutY(0);
} }
System.out.println("boatObjects = " + boatObjects.get(playerYacht).getBoatLayoutX()); // System.out.println("boatObjects = " + boatObjects.get(playerYacht).getBoatLayoutX());
System.out.println("boatObjects = " + boatObjects.get(playerYacht).getBoatLayoutY()); // System.out.println("boatObjects = " + boatObjects.get(playerYacht).getBoatLayoutY());
} }
public GameView () { public GameView () {
gameObjects = this.getChildren(); gameObjects = this.getChildren();
// create image view for map, bind panel size to image // create image view for map, bind panel size to image
gameObjects.add(mapImage); gameObjects.add(mapImage);
fpsDisplay.setLayoutX(5);
fpsDisplay.setLayoutY(20);
fpsDisplay.setStrokeWidth(2);
gameObjects.add(fpsDisplay);
gameObjects.add(raceBorder); gameObjects.add(raceBorder);
gameObjects.add(markers); gameObjects.add(markers);
initializeTimer(); initializeTimer();
@@ -631,4 +627,9 @@ public class GameView extends Pane {
}); });
} }
public void setFrameRateFXText(Text fpsDisplay) {
this.fpsDisplay = null;
this.fpsDisplay = fpsDisplay;
}
} }
@@ -71,6 +71,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
private Button selectAnnotationBtn; private Button selectAnnotationBtn;
@FXML @FXML
private ComboBox<Yacht> yachtSelectionComboBox; private ComboBox<Yacht> yachtSelectionComboBox;
@FXML
private Text fpsDisplay;
//Race Data //Race Data
private Map<Integer, Yacht> participants; private Map<Integer, Yacht> participants;
@@ -115,6 +117,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
initialiseSparkLine(); initialiseSparkLine();
gameView = new GameView(); gameView = new GameView();
gameView.setFrameRateFXText(fpsDisplay);
Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView)); Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView));
gameView.setBoats(new ArrayList<>(participants.values())); gameView.setBoats(new ArrayList<>(participants.values()));
gameView.updateBorder(raceData.getCourseLimit()); gameView.updateBorder(raceData.getCourseLimit());
+28 -1
View File
@@ -26,7 +26,34 @@
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="998.0" prefWidth="1530.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="998.0" prefWidth="1530.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController">
<children> <children>
<AnchorPane fx:id="contentAnchorPane" layoutX="322.0" layoutY="130.0" prefHeight="998.0" prefWidth="1281.0" style="-fx-background-color: skyblue;" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> <AnchorPane layoutX="322.0" layoutY="130.0" prefHeight="998.0" prefWidth="1281.0"
style="-fx-background-color: skyblue;" AnchorPane.bottomAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<GridPane prefHeight="998.0" prefWidth="1281.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="630.0" minWidth="10.0"
prefWidth="68.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1213.0" minWidth="10.0"
prefWidth="1213.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="489.0" minHeight="1.0" prefHeight="24.0"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="997.0" minHeight="10.0" prefHeight="974.0"
vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<AnchorPane fx:id="contentAnchorPane" prefHeight="200.0" prefWidth="200.0"
GridPane.columnSpan="2" GridPane.rowSpan="2"/>
<Text fx:id="fpsDisplay" strokeType="OUTSIDE" strokeWidth="0.0" text="60 FPS"
GridPane.halignment="CENTER" GridPane.valignment="CENTER"/>
</children>
</GridPane>
</children>
</AnchorPane>
<AnchorPane prefHeight="960.0" prefWidth="250.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0"> <AnchorPane prefHeight="960.0" prefWidth="250.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<children> <children>
<Label layoutX="11.0" layoutY="283.0" text="Team Position" textFill="WHITE" /> <Label layoutX="11.0" layoutY="283.0" text="Team Position" textFill="WHITE" />