fix incorrect calling of update method
This commit is contained in:
parent
6aefa559f4
commit
90684c084a
|
@ -86,7 +86,7 @@ public class Demux implements KeyListener, MouseListener {
|
|||
}
|
||||
|
||||
public void preRenderUpdate(int delta) {
|
||||
state.update(delta);
|
||||
state.preRenderUpdate(delta);
|
||||
}
|
||||
|
||||
public void render(Graphics g) {
|
||||
|
|
|
@ -96,6 +96,7 @@ public class DisplayContainer {
|
|||
timeSinceLastRender += delta;
|
||||
|
||||
input.poll(width, height);
|
||||
demux.update(delta);
|
||||
|
||||
int maxRenderInterval;
|
||||
if (Display.isVisible() && Display.isActive()) {
|
||||
|
@ -114,7 +115,7 @@ public class DisplayContainer {
|
|||
graphics.resetTransform();
|
||||
*/
|
||||
|
||||
demux.update(timeSinceLastRender);
|
||||
demux.preRenderUpdate(timeSinceLastRender);
|
||||
demux.render(graphics);
|
||||
|
||||
realRenderInterval = timeSinceLastRender;
|
||||
|
|
|
@ -26,6 +26,7 @@ import yugecin.opsudance.core.state.OpsuState;
|
|||
public class EmptyRedState implements OpsuState {
|
||||
|
||||
private int counter;
|
||||
private long start;
|
||||
|
||||
private final DisplayContainer displayContainer;
|
||||
|
||||
|
@ -38,6 +39,8 @@ public class EmptyRedState implements OpsuState {
|
|||
public void update(int delta) {
|
||||
counter -= delta;
|
||||
if (counter < 0) {
|
||||
counter = 10000; // to prevent more calls to switch, as this will keep rendingering untill state transitioned
|
||||
System.out.println(System.currentTimeMillis() - start);
|
||||
displayContainer.switchState(EmptyState.class);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +58,7 @@ public class EmptyRedState implements OpsuState {
|
|||
@Override
|
||||
public void enter() {
|
||||
counter = 5000;
|
||||
start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,6 +67,7 @@ public class EmptyRedState implements OpsuState {
|
|||
|
||||
@Override
|
||||
public boolean keyPressed(int key, char c) {
|
||||
System.out.println("pressed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -73,7 +78,6 @@ public class EmptyRedState implements OpsuState {
|
|||
|
||||
@Override
|
||||
public boolean mouseWheelMoved(int delta) {
|
||||
System.out.println("moved");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ public class EmptyState implements OpsuState {
|
|||
public void update(int delta) {
|
||||
counter -= delta;
|
||||
if (counter < 0) {
|
||||
counter = 10000; // to prevent more calls to switch, as this will keep rendingering untill state transitioned
|
||||
displayContainer.switchState(EmptyRedState.class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user