Animação

Ai galera eu ja to ficando doida … eu leio o core java e como programar akela parte de animação naum vejo como fazer o que o fessor pediu …

eu tentei fazer o programa do livro mas empaguei num erro … eu já naum sei o que fazer … olha os topicos ai …

[i]Utilizar ao menos uma vez cada uma das transformações lineares vistas em aula (translação, rotação e escala) (isso aki entre aspas eu sei ele deu em aula e estamos usando um programinha)

Usar threads na implementação da animação para evitar flickering. O uso da estratégia de buffering é opcional. (ãhhhmmm?!?!?!)

Não é estritamente necessário que haja interação com o usuário, se for uma animação. Jogos, entretanto, necessitam disso. Há bastante literatura e referências na Web a respeito de controles de interface em
Java (seja AWT ou Swing).

Em nenhuma hipótese o polígono descrito acima poderá deixar de ser usado.[/i]

opa blz??

manda o código com o stak trace dos erros!
aí agente da uma olhada e com certeza vc vai ser ajudada!

flws!

este exemplo foi tirado do livro core java 2 volume 2 pagina 48/49

[code]import java.awt.;
import java.awt.image.
;
import java.awt.event.;
import java.swing.
;
import java.net.*;

public class Animation extends JApplet
implements Runnable
{ public void init ()
{addMouseListener (new MouseAdapter()
{ public void mousePressed (MouseEvent evt)
{if(runner==null)
start();
else
stop();
}
});

try

{ imageName = getParameter (“imagename”);
if (imageName == null) ImageName = " ";

imageCount = 1;
String param = getParameter (“imagencount”);
if(param != null)
imagecount = Integer.parseInt (param);

}
catch (Exception e)
{ showStatus ("Error: " +e);
}
current = 0;
image = null;
loadImage ();

}

public void loadImage ()
{ try
{URL url= new URL (getDocumentBase (), imageName);
image = getImage(url);
MediaTracker tracker = new MediaTracker(this);
tracker.addImage (image, 0);
tracker.waitForID (0);
imageWidth = image.getWidth (null);
resize (imageWidth, ImageHeight / imageCount);
}

cath (InterruptedException e)
//lançada por mediatracker.waitfor
{ showStatus (“Loading Interrupted”);
}

catch (MalformedURLException e)
{ showStatus (“Bad URL”);

}
}

public void paint (Graphics g)
{if (image == null) return;
g.drawImage (image, 0, - (imageHeight / ImageCount) * current, null);
}

public void start ()
{ runner = new Thread (this);
runner.start();
showStatus(“click to stop”);
}

public void stop()
{ runner.interrupet();
runner = null;
showStatus (“Click to restart”);
}

public void run ()
{ try
{ while (! Thread.interrupted())
{ repaint ();
current = (current+1)%imageCount;
Thread.sleep (200);
}
}
catch (interruptedException e) {}
}
private Image image;
private init current;
private int imageCount;
private int imageWidth;
private int imageHeight;
private String imageName;
private Thread runner;

}
[/code]

os erros são :

C:\WINNT\Temp\conversao\Animation.java:40: 'try' without 'catch' or 'finally'
	{ try
          ^
C:\WINNT\Temp\conversao\Animation.java:50: ')' expected
cath (InterruptedException e)
                           ^
C:\WINNT\Temp\conversao\Animation.java:58: ';' expected
}
 ^
C:\WINNT\Temp\conversao\Animation.java:4: package java.swing does not exist
import java.swing.*;
^
C:\WINNT\Temp\conversao\Animation.java:7: cannot resolve symbol
symbol  : class JApplet 
location: class Animation
public class Animation extends JApplet
                               ^
C:\WINNT\Temp\conversao\Animation.java:89: cannot resolve symbol
symbol  : class init 
location: class Animation
private init current;
        ^
C:\WINNT\Temp\conversao\Animation.java:10: cannot resolve symbol
symbol  : method addMouseListener (<anonymous java.awt.event.MouseAdapter>)
location: class Animation
 {addMouseListener (new MouseAdapter()
  ^
C:\WINNT\Temp\conversao\Animation.java:21: cannot resolve symbol
symbol  : method getParameter (java.lang.String)
location: class Animation
{                imageName = getParameter ("imagename");
                             ^
C:\WINNT\Temp\conversao\Animation.java:22: cannot resolve symbol
symbol  : variable ImageName 
location: class Animation
  if (imageName == null) ImageName = " ";
                         ^
C:\WINNT\Temp\conversao\Animation.java:25: cannot resolve symbol
symbol  : method getParameter (java.lang.String)
location: class Animation
String param = getParameter ("imagencount");
               ^
C:\WINNT\Temp\conversao\Animation.java:27: cannot resolve symbol
symbol  : variable imagecount 
location: class Animation
imagecount = Integer.parseInt (param);
^
C:\WINNT\Temp\conversao\Animation.java:31: cannot resolve symbol
symbol  : method showStatus (java.lang.String)
location: class Animation
  { showStatus ("Error: " +e);
    ^
C:\WINNT\Temp\conversao\Animation.java:41: cannot resolve symbol
symbol  : method getDocumentBase ()
location: class Animation
		{URL  url= new  URL (getDocumentBase (), imageName);
                                     ^
C:\WINNT\Temp\conversao\Animation.java:42: cannot resolve symbol
symbol  : method getImage (java.net.URL)
location: class Animation
image = getImage(url);
        ^
C:\WINNT\Temp\conversao\Animation.java:47: cannot resolve symbol
symbol  : variable ImageHeight 
location: class Animation
resize (imageWidth, ImageHeight / imageCount);
                    ^
C:\WINNT\Temp\conversao\Animation.java:47: cannot resolve symbol
symbol  : method resize (int,int)
location: class Animation
resize (imageWidth, ImageHeight / imageCount);
^
C:\WINNT\Temp\conversao\Animation.java:50: cannot resolve symbol
symbol  : variable InterruptedException 
location: class Animation
cath (InterruptedException e)
      ^
C:\WINNT\Temp\conversao\Animation.java:63: cannot resolve symbol
symbol  : variable ImageCount 
location: class Animation
g.drawImage (image, 0,  - (imageHeight / ImageCount) * current, null);
                                         ^
C:\WINNT\Temp\conversao\Animation.java:67: reference to Thread is ambiguous, both method Thread(java.lang.Runnable) in java.lang.Thread and method Thread(java.lang.String) in java.lang.Thread match
{ runner = new Thread (this);
           ^
C:\WINNT\Temp\conversao\Animation.java:69: cannot resolve symbol
symbol  : method showStatus (java.lang.String)
location: class Animation
showStatus("click to stop");
^
C:\WINNT\Temp\conversao\Animation.java:73: cannot resolve symbol
symbol  : method interrupet ()
location: class java.lang.Thread
{ runner.interrupet();
        ^
C:\WINNT\Temp\conversao\Animation.java:75: cannot resolve symbol
symbol  : method showStatus (java.lang.String)
location: class Animation
showStatus ("Click to restart");
^
C:\WINNT\Temp\conversao\Animation.java:81: cannot resolve symbol
symbol  : method repaint ()
location: class Animation
 { repaint ();
   ^
C:\WINNT\Temp\conversao\Animation.java:82: operator % cannot be applied to java.lang.String,int
current = (current+1)%imageCount;
                     ^
C:\WINNT\Temp\conversao\Animation.java:86: cannot resolve symbol
symbol  : class interruptedException 
location: class Animation
catch (interruptedException e) {}
       ^
25 errors

Process completed.

pq será que alguns exercicios/exemplos tem muitos erros …

rs