Grape.Visualizer Class
An abstract class for visualizing different things. This class provides alpha and visible properties. It calls the visualize method with the rendering context in each render frame if visible is set to true.
Constructor
Grape.Visualizer
-
[opts]
Parameters:
-
[opts]
Object optionalInitial values of properties
Methods
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.
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:
-
event
StringEvent
-
handler
FunctionEvent listener
remove
()
Removes the instance from the layer.
visualize
-
ctx
This abstract method is called each render frame if visible is set to true.
Parameters:
-
ctx
CanvasRenderingContext2DThe rendering context
Properties
alpha
Number
The alpha value set before calling the visualize method
Default: 1
visible
Number
If set false, the visualize method is not called.
Default: true
x
Number
X coordinate
Default: 0
y
Number
Y coordinate
Default: 0