How to move Polygon Object with KeyListener in Java

后端 未结 3 1657
闹比i
闹比i 2020-12-22 06:32

I am working on a 2D game as a learning project and I have hit a bump. I cannot figure out how to move a Polygon object using the KeyListener within a JPanel (which is adde

3条回答
  •  一个人的身影
    2020-12-22 06:51

    Don't create a Frog in your paintComponent() method! That is throwing away the existing frog and creating a new one with default position. You should create all of your Frog instances when you initialize your panel, or possibly in response to a b button click to "create a new frog".

提交回复
热议问题