View Javadoc

1   package de.jos.game.objects.buttons;
2   
3   import de.jos.game.objects.screen.AbstractGameObject;
4   
5   public class QuitButton extends GameButton {
6   
7     /***
8      * Quit Button an angegebener Position erzeugen
9      * 
10     * @param gameObject
11     * @param x
12     * @param y
13     */
14    public QuitButton(AbstractGameObject gameObject, int x, int y) {
15      super(gameObject.getString("menu.quit"), x, y, 0, 0, gameObject);
16      // callback registrieren
17      setButtonClickCallback(new QuitButtonClickCallback(gameObject));
18    }
19  
20    @Override
21    public Action getAction() {
22      return Action.QUIT;
23    }
24  
25    /***
26     * Callback fuer einen Button click.
27     * 
28     * @author root
29     * 
30     */
31    private static final class QuitButtonClickCallback implements ButtonClickCallback {
32  
33      AbstractGameObject gameObject = null;
34  
35      public QuitButtonClickCallback(AbstractGameObject gameObject) {
36        this.gameObject = gameObject;
37      }
38  
39      /***
40       * {@inheritDoc}
41       */
42      public void performClickAction() {
43        gameObject.finish();
44      }
45  
46    }
47  
48  }