java.lang.Object <– greenfoot.Greenfoot
public class Greenfoot extends java.lang.Object
Per questo scopo si utilizzano i metodi getKey() e isKeyDown() che restituiscono/riconoscono i seguenti nomi per i tasti:
- a, b, .., z (alfabeto)
- getKey() restituisce correttamente anche i caratteri maiuscolo.
- 0..9 (cifre)
- la maggior parte dei segni di interpunzione…
- up, down, left, right (cursore)
- enter, space, tab, escape, backspace
- F1, F2, .., F12 (tasti funzione)
public Greenfoot()
public static java.lang.String getKey()
- Se non è stato premuto alcun tasto dall’ultima chiamata restituirà null.
- Se è stato premuto più di un tasto restituisce il tasto premuto più recentemente.
Restituisce:
public static boolean isKeyDown(java.lang.String nomeTasto)
Parametro:
Restituisce:
public static boolean mousePressed(java.lang.Object oggetto)
- If the parameter is an Actor the method will only return true if the mouse has been pressed on the given actor.
- If there are several actors at the same place, only the top most actor will receive the press.
- If the parameter is a World then true will be returned if the mouse was pressed on the world background.
- If the parameter is null, then true will be returned for any mouse press, independent of the target pressed on.
Parametro:
Restituisce:
public static boolean mouseClicked(java.lang.Object oggetto)
- If the parameter is an Actor the method will only return true if the mouse has been clicked on the given actor.
- If there are several actors at the same place, only the top most actor will receive the click.
- If the parameter is a World then true will be returned if the mouse was clicked on the world background.
- If the parameter is null, then true will be returned for any click, independent of the target clicked on.
Parametro:
Restituisce:
public static boolean mouseMoved(java.lang.Object oggetto)
- If the parameter is an Actor the method will only return true if the move is on the given actor.
- If there are several actors at the same place, only the top most actor will receive the move.
- If the parameter is null, then true will be returned for any move, independent of the target under the move location.
Parametro:
Restituisce:
public static boolean mouseDragged(java.lang.Object oggetto)
If there are several actors at the same place, only the top most actor will receive the drag.
If the parameter is a World then true will be returned if the drag action was started on the world background.
If the parameter is null, then true will be returned for any drag action, independent of the target clicked on.
Parametro:
Restituisce:
public static boolean mouseDragEnded(java.lang.Object oggetto)
If there are several actors at the same place, only the top most actor will receive the drag.
If the parameter is a World then true will be returned if the drag action was started on the world background.
If the parameter is null, then true will be returned for any drag action, independent of the target clicked on.
Parametro:
Restituisce:
public static MouseInfo getMouseInfo()
Restituisce:
public static int getRandomNumber(int limite)
public static void playSound(java.lang.String nomeFile)
Il nome del file può essere
- an absolute path
- a base name for a file located in the project directory
- oppure in the sounds directory of the project directory.
Parametro:
Throws:
public static void delay(int tempo)
La dimensione di ogni intervallo è definita dall’ambiente di Greenfoot (tramite cursore Velocità).
Parametro:
public static void setSpeed(int velocità)
Il valore deve essere compreso nell’intervallo 1..100.
Parametro:
public static void start()
public static void stop()