Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 17:22, 24 October 2007.

Como fazer um loop de animação

From Forum Nokia Wiki

Original: How to make an animation loop

Se você precisa fazer alguma animação no Java ME Canvas, você precisa usar um Game Loop usando multithreading.

O código será muito útil como um modelo (template) para fazer animações.

class MyAnimation extends Canvas implements Runnable {
 
   private Thread thread;
   private boolean executing;
   private final int SLEEP = 200;
 
   public void start() {
      executing=true;
      thread = new Thread(this);
      thread.start();
   }
 
   public void stop() {
       executing = false;
   }
 
   public void run() {
 
      // aqui, antes do loop, podem ser colocadas
      //ações de inicialização
 
      while (executing) {
         // movimenta os sprites para o proximo quadro (frame) da animação
         repaint();
         serviceRepaints(); // requisita que todos os pedidos de desenho
                            // pendentes sejam executados
      }
      try {
         // manda a thread aguardar(''sleep'') por alguns milisegundos
         Thread.sleep(SLEEP);
      } catch(Exception e) {} 
   }
 
   public void paint() {
       // desenha os objetos na tela
   }
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
How to introduce delay between Asynchronous calls? symbian_ravi Symbian Networking & Messaging 4 2005-10-18 08:42
How to load local text file into a Form? sogogo Mobile Java General 6 2002-10-01 13:14
How can I write an array into a textfile? manu.20 General Symbian C++ 1 2005-05-25 14:33
strange error miranda2112 General Symbian C++ 0 2005-10-19 05:08
App panics when deleting messages in inbox bjorn.rudolfsson Symbian Networking & Messaging 6 2005-05-26 03:41
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX