Animating an image in an Applet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaka123
    New Member
    • Dec 2007
    • 8

    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


    Code:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    public class applet311 extends JApplet
    {
     Thread t = new Thread();;
    
    
    
    		
    		
    	Image image; //an 'Image' object
    
    
    public void init()
    {
    
    image = getImage(getCodeBase(), "EdReed_large.gif");
    }
    public void paint(Graphics g)
    {
    
    g.setColor(Color.green);
    g.fillRect(0,0,500,500);
    
    for( int a=0;a<=1000;a+=10)
    {
    g.setColor(Color.white);
    g.drawLine(0,10+a,500,10+a);
    g.drawImage(image, 400, 0, this);
    
    
    
    
    }
    
    }
  • teek5449
    New Member
    • Jul 2007
    • 9

    #2
    You should take a quick look at THIS link. I think that is is exactly what you need to get going :)

    Comment

    • kaka123
      New Member
      • Dec 2007
      • 8

      #3
      thank you for providing me with the link

      Comment

      Working...