public void act() {
    // System.out.print("Score:" + score);
    setImage(new GreenfootImage("Health: 3, Score: " + score, 20, Color.GREEN, Color.BLACK));

    // creating next level

    if (score == level2) {
      setImage(new GreenfootImage("Level 2 Complete", 18, Color.YELLOW, Color.BLACK));
      Greenfoot.delay(200); // timer tampilan
      // getWorld().removeObject(this);
      Greenfoot.setWorld(new Level3()); // masuk ke Level3();
    }
  }
Exemplo n.º 2
0
  /**
   * entfernt die Mine und erzeugt 8 Splitter die in alle Richtungen fliegen soll später zusätzlich
   * sound abspielen und explosion darstellen
   */
  public void detonate() {
    int shrapnelnumber = 0;
    // erstellt 8 Splitter die nach der Detonation in alle Richtungen fliegen;
    while (shrapnelnumber != 8) {
      int shrapnelarc = shrapnelnumber * 45;

      Shrapnel name = new Shrapnel(shrapnelarc, shrapnelspeed);
      getWorld().addObject(name, this.getX(), this.getY());

      shrapnelnumber++;
    }
    this.setImage("explosion.gif");
    Greenfoot.playSound("explosion.wav");
    Greenfoot.delay(3);
    getWorld().removeObject(this);
  }