API Docs for: 1.0.1

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 optional

    Initial values of properties

Item Index

Properties

Methods

getGame

() Grape.Game | Null

Gets the current game instance through the current layer.

Returns:

Grape.Game | Null:

The current game, or null, if the lookup fails.

getLayer

() Grape.Layer

Returns the layer the instance is added to.

Returns:

Grape.Layer:

The layer

getScene

() Grape.Scene | Null

Gets the root layer.

Returns:

Grape.Scene | Null:

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 String

    Event

  • handler Function

    Event 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 CanvasRenderingContext2D

    The 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