lundi 12 février 2018

how do i pause my code from inside a switch (java)

I'm trying to make a small game inside a javafx application but the player(image) moves insanely fast so I tried using a Thread.sleep and TimeUnit.SECONDS.sleep but neither worked.

is it bacause I'm missing an import or the fact that I'm doing this inside a switch statement please help me.

                case W:
                    imgView.setRotate(270);
                    if (imgView.getY() >= 50) {
                        imgView.setY(imgView.getY() - 50);
                        TimeUnit.SECONDS.sleep(1);
                    }
                    break;

Aucun commentaire:

Enregistrer un commentaire