API Documentation for: 0.11.8
Show:

platypus.components.CameraFollowMe Class

This component can request that the camera focus on this entity.

Methods

'follow-me'

(
  • [options]
)

Defined in 'follow-me':91

On receiving this message, the component will trigger a message requesting that the parent camera begin following this entity.

Parameters:

  • [options] Object optional

    A list of key/value paris describing camera options to set.

    • [mode] String optional

      Camera following mode.

    • [top] Number optional

      The top of a bounding box.

    • [left] Number optional

      The left of a bounding box.

    • [width] Number optional

      The width of a bounding box.

    • [height] Number optional

      The height of a bounding box.

    • [offsetX] Number optional

      How far to offset the camera from the entity horizontally.

    • [offsetY] Number optional

      How far to offset the camera from the entity vertically.

    • [time] Number optional

      How many milliseconds to follow the entity.

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

camera

Object

Defined in camera:18

Sets initial camera settings when the entity is being followed. This can be over-written by the "follow-me" call itself. If any of these attributes are not provided, the following are used by default:

             {
                                                             "time": 500,
                                                             // Optional. Time in milliseconds that the camera should focus before returning to the original focus.
                                                             
                                                             "mode": "forward",
                                                             // Optional. Camera mode that the camera should use.
                                                             
                                                             "top": 100,
                                                             // Optional number specifying top of viewport in world coordinates
                                                             
                                                             "left": 100,
                                                             // Optional number specifying left of viewport in world coordinates
                                                             
                                                             "width": 100,
                                                             // Optional number specifying width of viewport in world coordinates
                                                             
                                                             "height": 100,
                                                             // Optional number specifying height of viewport in world coordinates
                                                             
                                                             "offsetX": 20,
                                                             // Optional number setting how far to offset the camera from the entity horizontally.
                                                             
                                                             "offsetY": 40
                                                             // Optional number setting how far to offset the camera from the entity vertically.
                                                         }

Default: {}

mode

String

Defined in mode:53

Camera mode that the camera should use.

Default: "forward"

pause

Boolean

Defined in pause:62

Whether to pause the game while the camera is focused.

Default: false

Events

'follow'

Defined in 'follow':145

This component fires this message on this entity's parent so the camera will begin following this entity.

Event Payload:

  • options Object

    A list of key/value pairs describing camera options to set.

    • entity platypus.Entity

      Sends this entity for the camera to follow.

    • mode String

      Camera following mode.

    • top Number

      The top of a bounding box.

    • left Number

      The left of a bounding box.

    • width Number

      The width of a bounding box.

    • height Number

      The height of a bounding box.

    • offsetX Number

      How far to offset the camera from the entity horizontally.

    • offsetY Number

      How far to offset the camera from the entity vertically.

    • time Number

      How many milliseconds to follow the entity.

'pause-logic'

Defined in 'pause-logic':126

This component fires this message on the parent entity to pause logic if required.

Event Payload:

  • options Object
    • time Number

      The amount of time to pause before re-enabling logic.

'pause-render'

Defined in 'pause-render':135

This component fires this message on the parent entity to pause rendering if required.

Event Payload:

  • options Object
    • time Number

      The amount of time to pause before re-enabling render updates.