Grape.Alarm Class
A utility class for creating timeouts in a game.
Constructor
Grape.Alarm
()
Item Index
Events
Methods
getAlarm
-
name
Returns the remaining frames of a timeout
Parameters:
-
nameStringAlarm name
Returns:
The remaining time
getGame
()
Grape.Game | Null
Gets the current game instance through the current layer.
Returns:
The current game, or null, if the lookup fails.
getScene
()
Grape.Scene | Null
Gets the root layer.
Returns:
The root layer, or null, if the lookup fails.
hasAlarm
-
id
Tells whether a timeout with a given name exists.
Parameters:
-
idStringName of the timeout
Returns:
true, if the timeout exists
increaseAlarm
-
name -
frames
Increases the duration of a timeout by a given amount. If timeout does not exist, the method creates it.
Parameters:
-
nameStringAlarm name
-
framesNumberNumber of frames to increase with
onGlobal
-
event -
handler
Subscribes to an event on the layer the instance is added to. If the instance is not yet added to any layers, it will subscribe when added.
Parameters:
-
eventStringEvent
-
handlerFunctionEvent listener
remove
()
Removes the instance from the layer.
setAlarm
-
name -
frames
Sets a timeout with a given name in frames.
Parameters:
-
nameStringAlarm name
-
framesNumberThe number of frames after the alarm triggers
Events
alarm
When a timeout ends, this event occurs. The parameter is the name of the timeout.
alarm.<name>
When a timeout ends, this event occurs too.
