v1.2.0: fixed input spam with new key movement logic

This commit is contained in:
Evan Debenham 2022-02-18 00:04:32 -05:00
parent 28f289e55e
commit 3bc9506eaa

View File

@ -304,6 +304,7 @@ public class CellSelector extends ScrollArea {
} else if (directionFromAction(action) != 0) {
lastCellMoved = -1;
if (heldAction1 == SPDAction.NONE){
heldAction1 = action;
heldDelay = 0.05f;
@ -332,9 +333,14 @@ public class CellSelector extends ScrollArea {
if (heldAction1 != SPDAction.NONE && Dungeon.hero.ready){
processKeyHold();
} else if (Dungeon.hero.ready) {
lastCellMoved = -1;
}
}
//prevents repeated inputs when the hero isn't moving
private int lastCellMoved = 0;
private boolean moveFromActions(GameAction... actions){
if (Dungeon.hero == null){
return false;
@ -345,7 +351,8 @@ public class CellSelector extends ScrollArea {
cell += directionFromAction(action);
}
if (cell != Dungeon.hero.pos){
if (cell != Dungeon.hero.pos && cell != lastCellMoved){
lastCellMoved = cell;
select(cell, PointerEvent.LEFT);
return true;
@ -372,8 +379,9 @@ public class CellSelector extends ScrollArea {
&& heldDelay <= 0){
enabled = Dungeon.hero.ready = true;
Dungeon.observe();
moveFromActions(heldAction1, heldAction2);
Dungeon.hero.ready = false;
if (moveFromActions(heldAction1, heldAction2)) {
Dungeon.hero.ready = false;
}
}
}