I want to make the pacman open/close mouth animation using the easiest method. Here is my recent code: The problem is, nothing is happening?
package ordner;
For the animation, you could use a Swing Timer to move the Pacman graphic as well as adjusting the angle by which the "mouth" opens, by varying the parameters used by fillArc
.
Interaction with KeyEvents
for movement control can be acheived using Key Bindings.
Also, I would move the paint
functionality to a paintComponent
method in a sub-classed JComponent
for better paint performance.
Related: Painting with Swing
Edit:
As youre starting Java there are a number of tasks to get working first
JComponent
based class with a static Pacman
graphic. Move your painting logic to paintComponent
Key Bindings