new ActiveTileLayer(activeTile, parent)
A layer displayed as part of an active tile.
Parameters
Name | Type | Description |
---|---|---|
activeTile |
Tily.ActiveTile | The top-level active tile that this layer belongs to. |
parent |
Tily.ActiveTile | Tily.ActiveTileLayer | The object that this layer belongs to. |
Extends
Members
animations :Array.<Tily.Animation>
The animations currently running on this active tile.
- Inherited From:
(nullable) centered :boolean
If the text in this tile should be centered. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
compositeMode :string
The composite operation to use when drawing this active tile.
- Inherited From:
- Default Value:
- "source-over"
(nullable) font :string
The font to use when rendering this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) fontSize :string
The font size to use when rendering this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) fontStyle :string
The font style to use when rendering this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) foreground :string
The foreground colour of this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
inheritedCentered :boolean
The centering mode in this layer or inherited from the parent object if null.
- Inherited From:
inheritedCompositeMode :string
The composite operation set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedFont :string
The font set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedFontSize :string
The font size set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedFontStyle :string
The font style set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedForeground :string
The foreground colour set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedOffset :Tily.utility.vec2
The offset set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedOpacity :number
The opacity set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedOutline :string
The outline set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedRotation :number
The rotation set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedScale :Tily.utility.vec2
The scale set in this layer or inherited from the parent object if null.
- Inherited From:
inheritedShadow :string
The shadow set in this layer or inherited from the parent object if null.
- Inherited From:
(nullable) offset :Tily.utility.vec2
The offset of this active tile measured in tiles. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) opacity :number
The opacity of this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) outline :string
The outline width and colour of this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) rotation :number
The rotation angle of this active tile measured in radians. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) scale :Tily.utility.vec2
The scale of this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
(nullable) shadow :string
The shadow width, offset and colour of this active tile. Set this to null to inherit from the parent object.
- Inherited From:
- Default Value:
- null
text :string
The string value to render for this active tile layer.
- Default Value:
- ""
Methods
(static) fromData(activeTile, parent, data) → {Tily.ActiveTileLayer}
Create an active tile layer from data.
Parameters
Name | Type | Description |
---|---|---|
activeTile |
Tily.ActiveTile | The top-level active tile that the layer belongs to. |
parent |
Tily.ActiveTile | Tily.ActiveTileLayer | The object that the layer belongs to. |
data |
Object | Serialized active tile layer data. |
addLayer(layer, zopt) → {Tily.ActiveTileLayer}
Add an active tile layer to this active tile at the specified z-index. If the z-index is undefined, add the layer on top of existing layers, and if the z-index is -1, add the layer below existing layers.
- Overrides:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
layer |
Tily.ActiveTileLayer | The layer to add. |
|
z |
number |
<optional> |
The z-index at which to add the layer. If this is -1, the layer will be added below existing layers and if it is undefined the layer will be added above existing layers. |
animateForeground(foreground, optionsopt)
Animate this active tile's foreground colour.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
foreground |
string | The target foreground colour. |
|
options |
AnimationOptions |
<optional> |
An optional options object. |
animateOffset(x, y, optionsopt)
Animate this active tile's offset.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
x |
number | The x-coordinate of the target offset position. |
|
y |
number | The y-coordinate of the target offset position. |
|
options |
OffsetAnimationOptions |
<optional> |
An optional options object. |
animateOpacity(opacity, optionsopt)
Animate this active tile's opacity.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
opacity |
number | The target opacity. |
|
options |
AnimationOptions |
<optional> |
An optional options object. |
animateOutline(outline, optionsopt)
Animate this active tile's outline.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
outline |
string | The target outline. |
|
options |
AnimationOptions |
<optional> |
An optional options object. |
animateRotation(angle, optionsopt)
Animate this active tile's rotation.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
angle |
number | The target angle in radians. |
|
options |
RotationAnimationOptions |
<optional> |
An optional options object. |
animateScale(x, y, optionsopt)
Animate this active tile's scale.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
x |
number | The target x-scale. |
|
y |
number | The target y-scale. |
|
options |
AnimationOptions |
<optional> |
An optional options object. |
animateShadow(shadow, optionsopt)
Animate this active tile's fshadow.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
shadow |
string | The target shadow. |
|
options |
AnimationOptions |
<optional> |
An optional options object. |
animateText(text, optionsopt)
Animate this active tile's text.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
text |
string | Array.<string> | animateTextFunction | If this is a string, the active tile's text will animate through each character one-by-one. If this is an array of strings, the active tile's text will animate through each string one-by-one. If this is a function, the initial text value and the interpolation value will be passed to it and the active tile's text will be set to the returned string. |
|
options |
AnimationOptions |
<optional> |
An optional options object. |
draw(context, elapsedTime, tileSize)
Render this active tile layer onto the buffer context.
- Overrides:
Parameters
Name | Type | Description |
---|---|---|
context |
CanvasRenderingContext2D | The context to draw this active tile layer onto. |
elapsedTime |
number | The time elapsed in seconds since the last draw call. |
tileSize |
number | The tile size measured in pixels. |
getData() → {Object}
Get serializable data for this active tile layer.
Returns
This active tile layer's data.
- Type
- Object
moveLayer(zFrom, zTo, relative) → {boolean}
Move a layer from one z-index to another z-index, either an absolute value or relative to the layer's current z-index.
- Inherited From:
Parameters
Name | Type | Description |
---|---|---|
zFrom |
number | The z-index of the layer to move. |
zTo |
number | The z-index to move the layer to. |
relative |
boolean | If this is true, the layer will be moved relative to it's current z-index. |
Returns
True if a layer was moved successfully.
- Type
- boolean
pauseAnimations(inheritopt)
Pause all animations below this layer.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
inherit |
boolean |
<optional> |
If true (default) then pass down to child layers |
removeLayer(zopt) → {Tily.ActiveTileLayer}
Remove a layer at the specified z-index. If the z-index is undefined, remove the top layer and if the z-index is -1, remove the bottom layer. The removed layer is returned.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
z |
number |
<optional> |
The z-index of the layer to remove. If this is -1, the bottom layer will be removed and if it is undefined the top layer will be removed. |
resetAnimations(inheritopt)
Reset all animations below this layer.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
inherit |
boolean |
<optional> |
If true (default) then pass down to child layers |
runAnimations(inheritopt)
Un-pause all animations below this layer.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
inherit |
boolean |
<optional> |
If true (default) then pass down to child layers |
stopAnimations(inheritopt)
Stop and remove all animations below this layer.
- Inherited From:
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
inherit |
boolean |
<optional> |
If true (default) then pass down to child layers |