API Documentation for: 0.11.8
Show:

platypus.components.RenderTiles Class

This component handles rendering tile map backgrounds.

When rendering the background, this component figures out what tiles are being displayed and caches them so they are rendered as one image rather than individually.

As the camera moves, the cache is updated by blitting the relevant part of the old cached image into a new cache and then rendering tiles that have shifted into the camera's view into the cache.

Methods

'add-tiles'

(
  • message.imageMap
)

Defined in 'add-tiles':404

This event adds a layer of tiles to render on top of the existing layer of rendered tiles.

Parameters:

  • message.imageMap Array

    This is a 2D mapping of tile indexes to be rendered.

'cache-sprite'

(
  • entity
)

Defined in 'cache-sprite':384

If this component should cache entities, it checks peers for a "renderCache" display object and adds the display object to its list of objects to render on top of the tile set.

Parameters:

  • entity platypus.Entity

    This is the peer entity to be checked for a renderCache.

'camera-loaded'

(
  • camera
)

Defined in 'camera-loaded':437

Provides the width and height of the world.

Parameters:

'camera-update'

(
  • camera
)

Defined in 'camera-update':454

Triggered when the camera moves, this function updates which tiles need to be rendered and caches the image.

Parameters:

  • camera Object

    Provides information about the camera.

    • viewport platypus.AABB

      The AABB describing the camera viewport in world units.

'change-tile'

(
  • tile
  • x
  • y
  • [z]
)

Defined in 'change-tile':419

This event edits the tile index of a rendered tile.

Parameters:

  • tile String

    A string representing the name of the tile to switch to.

  • x Number

    The column of the tile to edit.

  • y Number

    The row of the tile to edit.

  • [z] Number optional

    If RenderTiles has multiple layers, this value specifies the layer, with 0 being the bottom-most layer.

'handle-render'

()

Defined in 'handle-render':467

On receiving this message, determines whether to update which tiles need to be rendered and caches the image.

'handle-render-load'

(
  • data.container
)

This event is triggered before handle-render and provides the container that this component will require to display. In this case it compiles the array of tiles that make up the map and adds the tilesSprite displayObject to the stage.

Parameters:

  • data.container PIXI.Container

    Container to contain this tile-rendering.

'peer-entity-added'

(
  • entity
)

If this component should cache entities, it checks peers for a "renderCache" display object and adds the display object to its list of objects to render on top of the tile set.

Parameters:

  • entity platypus.Entity

    This is the peer entity to be checked for a renderCache.

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

buffer

Number

Defined in buffer:124

The amount of space in pixels around the edge of the camera that we include in the buffered image. If not set, largest buffer allowed by maximumBuffer is used.

Default: 0

cacheAll

Boolean

Defined in cacheAll:133

Determines whether to cache the entire map across one or more texture caches. By default this is false; however, if the entire map fits on one or two texture caches, this is set to true since it is more efficient than dynamic buffering.

Default: false

entityCache

Boolean

Defined in entityCache:142

Whether to cache entities on this layer if the entity's render component requests caching.

Default: false

imageMap

Array

Defined in imageMap:151

This is a two dimensional array of the spritesheet indexes that describe the map that you're rendering.

Default: []

left

Number

Defined in left:236

Available since 0.7.5

The map's left offset.

Default: 0

maximumBuffer

Number

Defined in maximumBuffer:160

The amount of space that is buffered. Defaults to 2048 x 2048 or a smaller area that encloses the tile layer.

Default: 2048

scaleX

Number

Defined in scaleX:169

The x-scale the tilemap is being displayed at.

Default: 1

scaleY

Number

Defined in scaleY:178

The y-scale the tilemap is being displayed at.

Default: 1

spriteSheet

Object | Array | String

Defined in spriteSheet:187

A sprite sheet describing all the tile images.

Accepts an array of sprite sheet data since 0.8.4

Default: null

tileCache

Boolean

Defined in tileCache:198

Available since 0.6.4

Whether to cache the tile map to a large texture.

Default: true

tileHeight

Number

Defined in tileHeight:208

This is the height in pixels of individual tiles.

Default: 10

tileWidth

Number

Defined in tileWidth:217

This is the width in pixels of individual tiles.

Default: 10

top

Number

Defined in top:226

Available since 0.7.5

The map's top offset.

Default: 0