Created a game where you need to move through the maze character. When you hold the button, for example, to the left, it once moved to the left, then stopped for about a second, and then it moves further normally. The question is, is it possible to somehow remove this delay? Example of movement to the left:
Main.pane.getScene().addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { switch (event.getCode()){ case A: moveLeft(); if(keys[0]){// проверка нажата ли кнопка вверх(нужно для //движения по диагонали) moveUp(); } if(keys[1]){ moveDown(); } break; } } }); The moveLeft function:
public void moveLeft(){ if(!IsIntersected(3)){ //проверка, есть ли впереди стена keys[2] = true; rect.setX(rect.getX() - step); Main.pane.setLayoutX(Main.pane.getLayoutX() + step); dir = Direction.Left; } else{ tpToWall(3); // если до стенки меньше шага то тогда телепортировать // к стенке }