Module.insertLayerAtIndex()

   
Type function
Library wattageTileEngine.Module.*
Return value VOID
Keywords  
See also  

Overview

This function will insert a layer in the module at the given index. If a layer already exists at the specified index, then the new layer will be inserted and all existing layers at that index or higher will be shifted one index higher.

When adding a layer, a scaling delta may be specified. This scaling delta indicates the difference in scaling from the layer with the next lower index.

The xScrollCoefficient and yScrollCoefficient parameters may be used to alter the rate of scrolling in X and Y directions for each layer. A value less than 1 will slow scrolling and a value greater than 1 will speed up scrolling.

The xOffset and yOffset parameters may be used to translate the layers in the X and Y directions.

Syntax

Module.insertLayerAtIndex( layer, index, scalingDelta, xScrollCoefficient, yScrollCoefficient, xOffset, yOffset )
layer (required)

Layer. The layer to add. This may be any layer type including the following:

index (required)

Number. The index to insert at.

scalingDelta (required)

Number. The difference in scaling between this layer and the layer before it.

xScrollCoefficient (optional)

Number. The coefficient applied to camera X position. This can be used to implement parallax scrolling. A value greater than 1 makes this scroll faster than the camera. A value smaller than 1 makes this scroll slower than the camera. The default value is 1 which results in a speed which matches the camera.

yScrollCoefficient (optional)

Number. The coefficient applied to camera Y position. This can be used to implement parallax scrolling. A value greater than 1 makes this scroll faster than the camera. A value smaller than 1 makes this scroll slower than the camera. The default value is 1 which results in a speed which matches the camera.

xOffset (optional)

Number. The amount to offset the layer in the X direction. This is in number of tiles, not pixels. If not specified, the default is 0.

yOffset (optional)

Number. The amount to offset the layer in the Y direction. This is in number of tiles, not pixels. If not specified, the default is 0.

Examples

moduleInstance.insertLayerAtIndex( myLayer, 3, 0.05 )