1 / 5

Animation

Animation. Albert Johnson Molly Richardson Andrew Kruth. Concepts. Threads Runnable interface sleep() GUIs repaint() paintComponent (). Quick Thread Review. Class that implements Runnable run() try – catch sleep() class MyThread implements Runnable {

hedy
Download Presentation

Animation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Animation Albert Johnson Molly Richardson Andrew Kruth

  2. Concepts • Threads • Runnable interface • sleep() • GUIs • repaint() • paintComponent()

  3. Quick Thread Review • Class that implements Runnable • run() • try – catch • sleep() • class MyThread implements Runnable { • public MyThread(…..parameters…..){ • ……..Initialize class variables…… • } • public void run() { • for........ { • Stuff…………. • try { Thread.sleep(DELAY); } • catch(InterruptedException e) {} • }

  4. Quick Thread Review cont… • Main class that creates your Runnable object • public static void main (String args[]) { • …..set your initial values….. • MyThread thread = new MyThread(..parameters..); • Thread t = new Thread(thread); • Thread.start(t); • }

  5. The Animation Part • Animation = threads + GUIs. • Basic Ideas for animation: • paintComponent() • this is where your GUIs will be. • MyThread • run() • This is where you change your positions • sleep() – necessary to be able to see the animation • repaint()

More Related