API Docs for:
Show:

Component_HotspotBehavior Class

Module: gs

Adds a hotspot-behavior to a game object. That allows a game object to respond to mouse/touch actions by firing an action-event or changing the game object's image.

Methods

checkShape

(
  • x
  • y
)

Checks if the specified point is inside of the hotspot's shape.

Parameters:

  • x Object
    • The x-coordinate of the point.
  • y Object
    • The y-coordinate of the point.

Returns:

If true the point is inside of the hotspot's shape. Otherwise false.

dispose

()

Disposes the component.

onDataBundleRestore.

(
  • Object
  • gs.ObjectCodecContext
)

Provided by the ui module.

Called if this object instance is restored from a data-bundle. It can be used re-assign event-handler, anonymous functions, etc.

Parameters:

  • Object Object

    data - The data-bundle

  • gs.ObjectCodecContext Object

    context - The codec-context.

setup

()

Initializes the hotspot component.

setupEventHandlers

()

Sets up event handlers.

update

()

Updates the hotspot component.

updateColor

() protected

Updates the game object's color depending on the state of the hotspot.

updateEvents

() protected

Updates the event-handling and fires necessary events.

updateFromTarget

() protected

Updates the hotspot position and size from an other target game object. For example, that is useful for adding a hotspot to an other moving game object.

updateImage

() protected

Updates the image depending on the hotspot state.

updateInput

() protected

Stores current states of mouse/touch pointer and buttons.

Properties

actionButton

Number

The default action-button. By default the left-button is used.

actionButtons

Object protected

buttonDown

Boolean protected

Indicates if the action-button is pressed.

buttonUp

Boolean protected

Indicates if the action-button was pressed before.

contains

Boolean protected

Indicates if the mouse/touch pointer is inside the hotspot bounds.

enabled

Boolean

Indicates if the hotspot is enabled.

imageHandling

Number protected

selected

Boolean

Indicates if the hotspot is selected.

shape

Boolean

The shape used to detect if a hotspot is clicked, hovered, etc.

sound

Object

The sound played if the hotspot action is executed.

sounds

Object

The sounds played depending on the hotspot state.

  • 0 = Select Sound
  • 1 = Unselect Sound