Displaying visual effect with imageview. #story[1292]
This commit is contained in:
@@ -13,6 +13,7 @@ import javafx.scene.PointLight;
|
||||
import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
@@ -69,6 +70,7 @@ public class RaceViewController extends Controller {
|
||||
private boolean mapToggle = true;
|
||||
private int heartbeatDelay = 1000;
|
||||
private long heartbeatTime = 0;
|
||||
private GPSConverter gpsConverter;
|
||||
|
||||
|
||||
/**
|
||||
@@ -100,6 +102,7 @@ public class RaceViewController extends Controller {
|
||||
private @FXML AnchorPane infoWrapper;
|
||||
private @FXML AnchorPane lineChartWrapper;
|
||||
private @FXML GridPane playerHealthContainer;
|
||||
private @FXML ImageView imageView;
|
||||
|
||||
/**
|
||||
* Displays a specified race.
|
||||
@@ -114,7 +117,6 @@ public class RaceViewController extends Controller {
|
||||
this.controllerClient = controllerClient;
|
||||
this.isHost = isHost;
|
||||
keyFactory.load();
|
||||
|
||||
tutorialCheck();
|
||||
initKeypressHandler();
|
||||
initialiseRaceVisuals();
|
||||
@@ -235,12 +237,19 @@ public class RaceViewController extends Controller {
|
||||
initialiseView3D(this.visualiserRace);
|
||||
initialiseHealthPane();
|
||||
initialiseRaceClock();
|
||||
initialiseFireEffect();
|
||||
raceTimer(); // start the timer
|
||||
new Sparkline(this.raceState, this.sparklineChart);
|
||||
timeZone.setText(this.raceState.getRaceClock().getTimeZone());
|
||||
arrowController.setWindProperty(this.raceState.windProperty());
|
||||
}
|
||||
|
||||
private void initialiseFireEffect(){
|
||||
Image fire = new Image(getClass().getClassLoader().getResourceAsStream("images/fire.gif"));
|
||||
imageView.setImage(fire);
|
||||
//imageView.setVisible(false);
|
||||
}
|
||||
|
||||
private void initialiseHealthPane() {
|
||||
InputStream tomato = this.getClass().getClassLoader().getResourceAsStream("visualiser/images/tomato.png");
|
||||
HealthSlider healthSlider = new HealthSlider(new Image(tomato));
|
||||
@@ -294,7 +303,7 @@ public class RaceViewController extends Controller {
|
||||
|
||||
// Set up projection from GPS to view
|
||||
RaceDataSource raceData = visualiserRace.getVisualiserRaceState().getRaceDataSource();
|
||||
final GPSConverter gpsConverter = new GPSConverter(raceData, 450, 450);
|
||||
gpsConverter = new GPSConverter(raceData, 450, 450);
|
||||
|
||||
SkyBox skyBox = new SkyBox(750, 200, 250, 0, 210);
|
||||
viewSubjects.addAll(skyBox.getSkyBoxPlanes());
|
||||
@@ -675,6 +684,15 @@ public class RaceViewController extends Controller {
|
||||
heartbeatDelay = 1000;
|
||||
}
|
||||
if(raceState.getBoat(raceState.getPlayerBoatID()).getHealth()<=40){
|
||||
imageView.setVisible(true);
|
||||
|
||||
imageView.setX(gpsConverter.convertGPS(raceState.getBoat(raceState.getPlayerBoatID()).getPosition()).getX());
|
||||
imageView.setY(gpsConverter.convertGPS(raceState.getBoat(raceState.getPlayerBoatID()).getPosition()).getY());
|
||||
System.out.println("Boat:" + gpsConverter.convertGPS(raceState.getBoat(raceState.getPlayerBoatID()).getPosition()).getX());
|
||||
System.out.println("Image:" + imageView.getX());
|
||||
|
||||
|
||||
//imageView.translateXProperty().setValue(raceState.getBoat(raceState.getPlayerBoatID()).getPosition().getLongitude());
|
||||
if(System.currentTimeMillis() > heartbeatTime+heartbeatDelay) {
|
||||
AudioClip sound = new AudioClip(this.getClass().getResource("/visualiser/sounds/heartbeat.mp3").toExternalForm());
|
||||
sound.play();
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.chart.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.chart.LineChart?>
|
||||
<?import javafx.scene.chart.NumberAxis?>
|
||||
@@ -23,7 +30,7 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<SplitPane fx:id="racePane" prefHeight="431.0" prefWidth="610.0" visible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceViewController">
|
||||
<SplitPane fx:id="racePane" prefHeight="431.0" prefWidth="610.0" visible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceViewController">
|
||||
<items>
|
||||
<StackPane fx:id="newPane" prefHeight="150.0" prefWidth="200.0">
|
||||
<children>
|
||||
@@ -179,6 +186,7 @@
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<ImageView fx:id="imageView" fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="infoWrapper" focusTraversable="true" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0" visible="false">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.chart.*?>
|
||||
@@ -28,11 +29,7 @@
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<SplitPane fx:id="racePane" dividerPositions="1.0" prefHeight="431.0"
|
||||
prefWidth="610.0" visible="true" AnchorPane.bottomAnchor="0.0"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
||||
AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8.0.65"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceViewController">
|
||||
<SplitPane fx:id="racePane" dividerPositions="1.0" prefHeight="431.0" prefWidth="610.0" visible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceViewController">
|
||||
<items>
|
||||
<StackPane fx:id="newPane" prefHeight="150.0" prefWidth="200.0">
|
||||
<children>
|
||||
@@ -113,6 +110,15 @@
|
||||
</children>
|
||||
</StackPane>
|
||||
<Label fx:id="tutorialText" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" style="-fx-border-color: orange; -fx-border-radius: 5px; -fx-background-color: #ffffcc; -fx-text-fill: #3399ff; -fx-border-width: 3; -fx-border-insets: -3;" text="This is the tutorial text" visible="false" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="150.0" AnchorPane.topAnchor="100.0" />
|
||||
<StackPane prefHeight="150.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../../../../../../../../../../../../../opt/JavaFXSceneBuilder2.0/app/fxml-16.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</children>
|
||||
</StackPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user