Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old September 30th, 2008, 09:38 PM
Newbie
 
Join Date: Dec 2007
Posts: 8
Default Animating an image in an Applet

Hi ive decided to make an applet where i would like my favorite player ed reed to run accross the screen with the ball in his hand, and i was wondering how i can animate him to do that..ive used the repaint function with a try sleep before so thats all i really am not sure how to do.. what would be a base code for this? im sure its hard if sice you dont have the file, but mabye you can give me a little back round

thanks


Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.applet.*;
  4. import javax.swing.*;
  5. public class applet311 extends JApplet
  6. {
  7.  Thread t = new Thread();;
  8.  
  9.  
  10.  
  11.  
  12.  
  13.     Image image; //an 'Image' object
  14.  
  15.  
  16. public void init()
  17. {
  18.  
  19. image = getImage(getCodeBase(), "EdReed_large.gif");
  20. }
  21. public void paint(Graphics g)
  22. {
  23.  
  24. g.setColor(Color.green);
  25. g.fillRect(0,0,500,500);
  26.  
  27. for( int a=0;a<=1000;a+=10)
  28. {
  29. g.setColor(Color.white);
  30. g.drawLine(0,10+a,500,10+a);
  31. g.drawImage(image, 400, 0, this);
  32.  
  33.  
  34.  
  35.  
  36. }
  37.  
  38. }
  39.  
Reply
  #2  
Old September 30th, 2008, 10:02 PM
Newbie
 
Join Date: Jul 2007
Posts: 6
Default

You should take a quick look at THIS link. I think that is is exactly what you need to get going :)
Reply
  #3  
Old September 30th, 2008, 10:44 PM
Newbie
 
Join Date: Dec 2007
Posts: 8
Default

thank you for providing me with the link
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.