API Documentation for: 0.11.8
Show:

platypus.components.LogicButton Class

Provides button functionality for a RenderSprite component.

Methods

'camera-update'

(
  • camera
)

Defined in 'camera-update':180

Available since 0.9.0

This component listens for camera updates to reposition the entity if its bottom, left, right, or top properties have been set.

Parameters:

  • camera platypus.Data

    Camera update information

    • viewport platypus.AABB

      The bounding box describing the camera viewport location in the world.

'disable'

()

Defined in 'disable':321

Disables the entity.

'enable'

()

Defined in 'enable':331

Enables the entity.

'handle-logic'

()

Defined in 'handle-logic':159

Available since 0.11.5

This component uses location updates to reposition the entity if its bottom, left, right, or top properties have been set.

'highlight'

()

Defined in 'highlight':353

Available since 0.8.6

Sets the entity's highlighted state to true.

'mousedown'

()

Defined in 'mousedown':193

Triggers events per the component's definition when a press is made.

'mouseout'

()

Defined in 'mouseout':310

If a press moves off of the button, it's cancelled.

'mouseover'

()

Defined in 'mouseover':296

If a press moves over the button, it's not cancelled.

'pressup'

()

Defined in 'pressup':230

Triggers events per the component's definition when a press is released.

'toggle-disabled'

()

Toggles whether the entity is disabled.

'toggle-highlight'

()

Defined in 'toggle-highlight':373

Available since 0.8.6

Toggles the entity's highlighted state.

'unhighlight'

()

Defined in 'unhighlight':363

Available since 0.8.6

Sets the entity's highlighted state to false.

addEventListener

(
  • event
  • callback
)
Function private
This method adds an event listener to the entity.

Parameters:

  • event String
    The event that this component should listen for.
  • callback Function
    The handler for the event.

Returns:

Function: handler A reference to the bound handler.

addMethod

(
  • name
  • func
)
private
This method adds a method to the entity.

Parameters:

  • name String
    The name of the method. For example, if name is "turnYellow", the method is accessible on the entity as entity.turnYellow().
  • func Function
    The function describing the method.

destroy

() private

Inherited from platypus.Component: destroy:54

This method cleans up listeners and methods that this component added to the entity. It should never be called by the component itself. Call this.owner.removeComponent(this) instead.

getAssetList

(
  • definition
  • properties
  • defaultProperties
)
Array
This method can be overwritten to provide the list of assets this component requires. This method is invoked when the list of game scenes is created to determine assets for each scene.

Parameters:

  • definition Object
    The definition for the component.
  • properties Object
    The properties of the Entity.
  • defaultProperties Object
    The default properties of the Entity.

Returns:

Array: A list of the necessary assets to load.

getLateAssetList

(
  • data
)
Array
This method can be overwritten to provide the list of assets this component requires. This method is invoked when the list of game scenes is created to determine assets for each scene.

Parameters:

  • data Object
    Scene data that affects the list of assets.

Returns:

Array: A list of the necessary assets to load.

removeEventListener

(
  • event
  • callback
)
private
This method removes an event listener from the entity.

Parameters:

  • event String
    The event for which to remove a listener.
  • callback Function
    The listener to remove. If not supplied, all event listeners for the provided event are removed.

removeEventListeners

(
  • [listeners]
)
private
This method removes multiple event listeners from the entity.

Parameters:

  • [listeners] Array optional
    The list of listeners to remove. If not supplied, all event listeners are removed.

removeMethod

(
  • name
)
private
This method removes a method from the entity.

Parameters:

  • name String
    The name of the method to be removed.

toJSON

() Object

Inherited from platypus.Component: toJSON:45

Available since 0.11.0

Returns a JSON object describing the component.

Returns:

Object: Returns a JSON definition that can be used to recreate the component.

toString

() String
Returns a string describing the component.

Returns:

String: Returns the component type as a string of the form "[Component ComponentType]".

Properties

bottom

Number

Defined in bottom:97

Available since 0.9.0

This sets the distance in world units from the bottom of the camera's world viewport. If set, it will override the entity's y coordinate. This property is accessible on the entity as entity.bottom.

Default: null

disabled

Boolean

Defined in disabled:66

Whether this button should start disabled.

Default: false

hoverAudio

String or an Array of Strings and Message Objects

Defined in hoverAudio:47

Available since 0.9.0

The event to trigger when the user mouses over the button

Default: ""

left

Number

Defined in left:107

Available since 0.9.0

This sets the distance in world units from the left of the camera's world viewport. If set, it will override the entity's x coordinate. This property is accessible on the entity as entity.left.

Default: null

onCancel

String

Defined in onCancel:38

The event to trigger when cancelled.

Default: ""

onPress

String

Defined in onPress:20

The event to trigger when pressed.

Default: ""

onRelease

String

Defined in onRelease:29

The event to trigger when released.

Default: ""

pressed

Boolean

Defined in pressed:85

Available since 0.9.1

Specifies whether the button starts off 'pressed'; typically only useful for toggle buttons.

Default: false

right

Number

Defined in right:117

Available since 0.9.0

This sets the distance in world units from the right of the camera's world viewport. If set, it will override the entity's x coordinate. This property is accessible on the entity as entity.right.

Default: null

toggle

Boolean

Defined in toggle:75

Available since 0.9.1

Determines whether this button should behave as a toggle.

Default: false

top

Number

Defined in top:127

Available since 0.9.0

This sets the distance in world units from the top of the camera's world viewport. If set, it will override the entity's y coordinate. This property is accessible on the entity as entity.top.

Default: null

useOnce

Boolean

Defined in useOnce:57

Whether this button's actions should be limited to the initial press/release.

Default: false

Events

'cancelled'

Defined in 'cancelled':244

Available since 0.9.1

This event is triggered when the button is pressed and the mouse/touch is dragged off-target before release.

Event Payload:

  • buttonState platypus.Data

    The state of the button

    • pressed Boolean

      This is false for the 'cancelled' event.

    • released Boolean

      This is true for the 'cancelled' event.

    • triggered Boolean

      This is false for the 'cancelled' event.

'pressed'

Defined in 'pressed':207

Available since 0.9.1

This event is triggered when the button is pressed to mimic keypress events. If the button is a toggle button, this only occurs on up-to-down.

Event Payload:

  • buttonState platypus.Data

    The state of the button

    • pressed Boolean

      This is true for the 'pressed' event.

    • released Boolean

      This is false for the 'pressed' event.

    • triggered Boolean

      This is true for the 'pressed' event.

'released'

Defined in 'released':268

Available since 0.9.1

This event is triggered when the button is released, or on the down-to-up change for toggle buttons.

Event Payload:

  • buttonState platypus.Data

    The state of the button

    • pressed Boolean

      This is false for the 'released' event.

    • released Boolean

      This is true for the 'released' event.

    • triggered Boolean

      This is false for the 'released' event.