1     /**
2      * Curso Básico de desarrollo de Juegos en Java - Invaders
3      * 
4      * (c) 2004 Planetalia S.L. - Todos los derechos reservados. Prohibida su reproducción
5      * 
6      * http://www.planetalia.com
7      * 
8      */
9     package version13;
10    
11    import java.awt.Graphics2D;
12    import java.awt.image.BufferedImage;
13    
14    public class Actor {
15      protected int x,y;
16      protected int width, height;
17      protected String spriteName;
18      protected Stage stage;
19      protected SpriteCache spriteCache;
20      
21      public Actor(Stage stage) {
22        this.stage = stage;
23        spriteCache = stage.getSpriteCache();
24      }
25      
26      public void paint(Graphics2D g){
27        g.drawImage( spriteCache.getSprite(spriteName), x,y, stage );
28      }
29      
30      public int getX()  { return x; }
31      public void setX(int i) { x = i; }
32    
33      public int getY() { return y; }
34      public void setY(int i) { y = i; }
35      
36      public String getSpriteName() { return spriteName; }
37      public void setSpriteName(String string) { 
38        spriteName = string;
39        BufferedImage image = spriteCache.getSprite(spriteName);
40        height = image.getHeight();
41        width = image.getWidth();
42      }     
43      
44      public int getHeight() { return height; }
45      public int getWidth() { return width; }
46      public void setHeight(int i) {height = i; }
47      public void setWidth(int i) { width = i;  }
48    
49      public void act() { }
50    }
51