recalculate length and times every x ms when moving
This commit is contained in:
parent
bf2e71e39b
commit
414e20ec26
|
@ -41,11 +41,14 @@ public class StoryboardMoveImpl implements StoryboardMove {
|
||||||
|
|
||||||
private float totalLength;
|
private float totalLength;
|
||||||
|
|
||||||
|
private int recalculateDelay;
|
||||||
|
|
||||||
public StoryboardMoveImpl(Vec2f start, Vec2f end) {
|
public StoryboardMoveImpl(Vec2f start, Vec2f end) {
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
movers = new ArrayList<>();
|
movers = new ArrayList<>();
|
||||||
midPoints = new ArrayList<>();
|
midPoints = new ArrayList<>();
|
||||||
|
recalculateDelay = 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,6 +94,12 @@ public class StoryboardMoveImpl implements StoryboardMove {
|
||||||
public void update(int delta, int x, int y) {
|
public void update(int delta, int x, int y) {
|
||||||
if (currentPoint != null) {
|
if (currentPoint != null) {
|
||||||
moveCurrentPoint(x, y);
|
moveCurrentPoint(x, y);
|
||||||
|
recalculateDelay -= delta;
|
||||||
|
if (recalculateDelay < 0) {
|
||||||
|
recalculateDelay = 700;
|
||||||
|
recalculateLengths();
|
||||||
|
recalculateTimes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,13 +121,10 @@ public class StoryboardMoveImpl implements StoryboardMove {
|
||||||
public void mouseReleased(int x, int y) {
|
public void mouseReleased(int x, int y) {
|
||||||
if (currentPoint != null) {
|
if (currentPoint != null) {
|
||||||
moveCurrentPoint(x, y);
|
moveCurrentPoint(x, y);
|
||||||
totalLength -= prevMover.getLength() + nextMover.getLength();
|
recalculateLengths();
|
||||||
prevMover.recalculateLength();
|
|
||||||
nextMover.recalculateLength();
|
|
||||||
totalLength += prevMover.getLength() + nextMover.getLength();
|
|
||||||
currentPoint = null;
|
currentPoint = null;
|
||||||
recalculateTimes();
|
|
||||||
}
|
}
|
||||||
|
recalculateDelay = 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,6 +134,14 @@ public class StoryboardMoveImpl implements StoryboardMove {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void recalculateLengths() {
|
||||||
|
totalLength -= prevMover.getLength() + nextMover.getLength();
|
||||||
|
prevMover.recalculateLength();
|
||||||
|
nextMover.recalculateLength();
|
||||||
|
totalLength += prevMover.getLength() + nextMover.getLength();
|
||||||
|
recalculateTimes();
|
||||||
|
}
|
||||||
|
|
||||||
private void moveCurrentPoint(int x, int y) {
|
private void moveCurrentPoint(int x, int y) {
|
||||||
currentPoint.x = x;
|
currentPoint.x = x;
|
||||||
currentPoint.y = y;
|
currentPoint.y = y;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user