v1.2.0: fixed input spam with new key movement logic
This commit is contained in:
parent
28f289e55e
commit
3bc9506eaa
|
@ -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,10 +379,11 @@ public class CellSelector extends ScrollArea {
|
|||
&& heldDelay <= 0){
|
||||
enabled = Dungeon.hero.ready = true;
|
||||
Dungeon.observe();
|
||||
moveFromActions(heldAction1, heldAction2);
|
||||
if (moveFromActions(heldAction1, heldAction2)) {
|
||||
Dungeon.hero.ready = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetKeyHold(){
|
||||
heldAction1 = heldAction2 = heldAction3 = SPDAction.NONE;
|
||||
|
|
Loading…
Reference in New Issue
Block a user