v1.2.0: fixed input spam with new key movement logic
This commit is contained in:
@@ -304,6 +304,7 @@ public class CellSelector extends ScrollArea {
|
|||||||
|
|
||||||
} else if (directionFromAction(action) != 0) {
|
} else if (directionFromAction(action) != 0) {
|
||||||
|
|
||||||
|
lastCellMoved = -1;
|
||||||
if (heldAction1 == SPDAction.NONE){
|
if (heldAction1 == SPDAction.NONE){
|
||||||
heldAction1 = action;
|
heldAction1 = action;
|
||||||
heldDelay = 0.05f;
|
heldDelay = 0.05f;
|
||||||
@@ -332,9 +333,14 @@ public class CellSelector extends ScrollArea {
|
|||||||
|
|
||||||
if (heldAction1 != SPDAction.NONE && Dungeon.hero.ready){
|
if (heldAction1 != SPDAction.NONE && Dungeon.hero.ready){
|
||||||
processKeyHold();
|
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){
|
private boolean moveFromActions(GameAction... actions){
|
||||||
if (Dungeon.hero == null){
|
if (Dungeon.hero == null){
|
||||||
return false;
|
return false;
|
||||||
@@ -345,7 +351,8 @@ public class CellSelector extends ScrollArea {
|
|||||||
cell += directionFromAction(action);
|
cell += directionFromAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell != Dungeon.hero.pos){
|
if (cell != Dungeon.hero.pos && cell != lastCellMoved){
|
||||||
|
lastCellMoved = cell;
|
||||||
select(cell, PointerEvent.LEFT);
|
select(cell, PointerEvent.LEFT);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -372,8 +379,9 @@ public class CellSelector extends ScrollArea {
|
|||||||
&& heldDelay <= 0){
|
&& heldDelay <= 0){
|
||||||
enabled = Dungeon.hero.ready = true;
|
enabled = Dungeon.hero.ready = true;
|
||||||
Dungeon.observe();
|
Dungeon.observe();
|
||||||
moveFromActions(heldAction1, heldAction2);
|
if (moveFromActions(heldAction1, heldAction2)) {
|
||||||
Dungeon.hero.ready = false;
|
Dungeon.hero.ready = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user