My Project
 Todo Clases Archivos Funciones Variables
Reloj.java
Ir a la documentación de este archivo.
1 import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
2 
9 public class Reloj extends Tiempo
10 {
11  private GreenfootImage img;//Variable que se va a utilizar para crear un objeto imagen.
12  private int band;//Variable que indica si el jugador tomo el tiempo.
13 
17  public Reloj()
18  {
19  img = new GreenfootImage("reloj.png");
20  img.scale(50,50);
21  band = 0;
22  setImage(img);
23  }
24 
28  public void act()
29  {
30  setImage(img);
31  move(-4);
33  limite();
34  }
35 
39  public void chocaPersonaje()
40  {
41  Actor act = getOneIntersectingObject(Personaje.class);
42  if(act != null)
43  {
44  ((Mundo)getWorld()).incrementa();
45  band = 1;
46  }
47  }
48 
52  public void limite()
53  {
54  if(getX() == 0 || band == 1)
55  {
56  ((Mundo)getWorld()).mandaTiempo();
57  getWorld().removeObject(this);
58  }
59  }
60 }