Results 1 to 3 of 3
Thread: Rain animation help
- 01-14-2012, 10:40 PM #1
Member
- Join Date
- Jan 2012
- Location
- The Coffee Pot
- Posts
- 36
- Rep Power
- 0
Rain animation help
Sorry no code because I attempted and it was a trainwreck so i'm back to square one. I'm just trying to create randomized rain on a jpanel by drawing lines about 4 pixels long using a Timer and actionPerformed() to do it. There's already stuff drawn on the panel so some of my thoughts are: on the same panel?, on a transparent panel on top of it?, something with an array?, use Math.random()?(I am), create lots of raindrop objects?(failed that route). I'm just looking for some suggestions or pointers in the right direction, thanks.
- 01-14-2012, 11:19 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Re: Rain animation help
You are on the right track.
Use a Swing Timer to schedule the animation. In the paintComponent() code you will probably need an ArrayList of raindrop objects that you want to paint. When the Timer fires you just invoke repaint() on the panel. Then the custom painting code will loop through the ArrayList of raindrops.
- 01-14-2012, 11:47 PM #3
Member
- Join Date
- Jan 2012
- Location
- The Coffee Pot
- Posts
- 36
- Rep Power
- 0
Similar Threads
-
Animation
By ryainad in forum Advanced JavaReplies: 1Last Post: 04-04-2011, 05:52 PM -
Fish animation
By SwEeTAcTioN in forum AWT / SwingReplies: 3Last Post: 11-30-2009, 10:56 AM -
need help about animation ?
By h9h in forum Java 2DReplies: 1Last Post: 10-30-2009, 11:41 AM -
JTextArea Animation
By hoglu in forum New To JavaReplies: 1Last Post: 12-18-2008, 11:44 AM -
GUI Animation
By serfster in forum New To JavaReplies: 2Last Post: 06-11-2008, 03:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks