I have a Duck Shooter game to make using Java Swing. I know I can make a Button register number of clicks or cover other buttons. How do I make it move from left to right and then when it disappears on the right it counts as losing a life? I need 3 difficulties so I'd probably make their speed change based on that.
Asked
Active
Viewed 24 times
-1
-
1You use a Swing Timer for animation. Check out: https://stackoverflow.com/questions/54028090/get-width-and-height-of-jpanel-outside-of-the-class/54028681#54028681 for an example of animating the movement of multiple "ball" objects on the screen. – camickr May 27 '22 at 18:38
-
Instead of moving `JButtons`, draw shapes on a drawing `JPanel`. Oracle has a helpful tutorial, [Creating a GUI With Swing](https://docs.oracle.com/javase/tutorial/uiswing/index.html). Skip the Learning Swing with the NetBeans IDE section. Pay close attention to the [Concurrency in Swing](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html) and [Performing Custom Painting](https://docs.oracle.com/javase/tutorial/uiswing/painting/index.html) sections. – Gilbert Le Blanc May 27 '22 at 20:15