Fixed juttery movements when zooming and sometimes tracking.

Need to look into getting the boat propery fixed in the center.

#story[1121]
This commit is contained in:
Kusal Ekanayake
2017-08-15 19:14:16 +12:00
parent fab5f9229f
commit 7fbecc8b3d
2 changed files with 13 additions and 9 deletions
@@ -229,7 +229,6 @@ public class GameClient {
positionData.getLon(), positionData.getHeading(), positionData.getLon(), positionData.getHeading(),
positionData.getGroundSpeed()); positionData.getGroundSpeed());
} }
raceView.getGameView().trackBoat();
} else if (positionData.getType() == DeviceType.MARK_TYPE) { } else if (positionData.getType() == DeviceType.MARK_TYPE) {
//CompoundMark mark = courseData.getCompoundMarks().get(positionData.getDeviceId()); //CompoundMark mark = courseData.getCompoundMarks().get(positionData.getDeviceId());
} }
+13 -8
View File
@@ -91,15 +91,15 @@ public class GameView extends Pane {
double scaleFactor = 1; double scaleFactor = 1;
public void zoomOut() { public void zoomOut() {
scaleFactor = 0.05; scaleFactor = 0.95;
this.setScaleX(this.getScaleX() - scaleFactor); this.setScaleX(this.getScaleX() * scaleFactor);
this.setScaleY(this.getScaleY() - scaleFactor); this.setScaleY(this.getScaleY() * scaleFactor);
} }
public void zoomIn() { public void zoomIn() {
scaleFactor = 0.05; scaleFactor = 1.05;
this.setScaleX(this.getScaleX() + scaleFactor); this.setScaleX(this.getScaleX() * scaleFactor);
this.setScaleY(this.getScaleY() + scaleFactor); this.setScaleY(this.getScaleY() * scaleFactor);
} }
private enum ScaleDirection { private enum ScaleDirection {
@@ -118,8 +118,12 @@ public class GameView extends Pane {
double y = boat.getBoatLayoutY(); double y = boat.getBoatLayoutY();
double displacementX = this.getWidth(); double displacementX = this.getWidth();
double displacementY = this.getHeight(); double displacementY = this.getHeight();
this.setLayoutX((-x + ((displacementX)/2.0)) * this.getScaleX()); // double displacementX = 1200d;
this.setLayoutY((-y + ((displacementY)/2.0)) * this.getScaleY()); // double displacementY = 900d;
System.out.println("displacementY = " + displacementY);
System.out.println("displacementX = " + displacementX);
this.setLayoutX((-x + (displacementX/2.0)) * this.getScaleX());
this.setLayoutY((-y + (displacementY/2.0)) * this.getScaleY());
} }
} }
if (!isBoatSelected) { if (!isBoatSelected) {
@@ -153,6 +157,7 @@ public class GameView extends Pane {
@Override @Override
public void handle(long now) { public void handle(long now) {
trackBoat();
if (lastTime == 0) { if (lastTime == 0) {
lastTime = now; lastTime = now;
} else { } else {