new ActiveTile(xopt, yopt, zIndexopt)
A tile that can be translated, scaled, rotated and animated.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number |
<optional> |
0 | The initial x-coordinate of this active tile. |
y |
number |
<optional> |
0 | The initial y-coordinate of this active tile. |
zIndex |
number |
<optional> |
0 | The initial z-index of this active tile. |
Extends
Members
animations :Array.<Tily.Animation>
The animations currently running on this active tile.
- Inherited From:
centered :boolean
True if the text in this active tile should be centered.
- Overrides:
- Default Value:
- false
clip :boolean
True if this active tile should clip at the tile edges.
- Default Value:
- false
compositeMode :string
The composite operation to use when drawing this active tile.
- Overrides:
- Default Value:
- "source-over"
destroyed :boolean
True if this active tile should be removed in the next frame.
- Default Value:
- false
flip :boolean
True if this active tile should be flipped along the x-axis.
- Default Value:
- false
font :string
The font to use when rendering this active tile's layers.
- Overrides:
- Default Value:
- "sans-serif"
(nullable) fontSize :string
The font size to use when rendering this active tile's layers. If null, fit characters to the tile.
- Overrides:
- Default Value:
- null
fontStyle :string
The font style to use when rendering this active tile's layers.
- Overrides:
- Default Value:
- "normal"
foreground :string
The foreground colour, used for rendering text on this active tile's layers.
- Overrides:
- Default Value:
- "white"
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:
offset :Tily.utility.vec2
An offset from this active tile's position measured in tiles.
- Overrides:
- Default Value:
- { x: 0, y: 0 }
opacity :number
The opacity of this active tile.
- Overrides:
- Default Value:
- 1
(nullable) outline :string
The outline width and colour for this active tile's layers.
- Overrides:
- Default Value:
- null
rotation :number
The rotation angle of this active tile measured in radians.
- Overrides:
- Default Value:
- 0
(nullable) shadow :string
The shadow amount, offset and colour for this active tile's layers.
- Overrides:
- Default Value:
- null
wrap :boolean
True if this active tile should wrap around tile edges.
- Default Value:
- false
Methods
(static) fromData(data) → {Tily.ActiveTile}
Create an active tile from data.
Parameters
Name | Type | Description |
---|---|---|
data |
Object | Serialized active tile data. |
addLayer(layernullable, 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 |
<nullable> |
The layer to add. If this is null, a new layer will be created. |
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. |
draw(context, elapsedTime, tileSize)
Render this active tile onto the container context.
- Overrides:
Parameters
Name | Type | Description |
---|---|---|
context |
CanvasRenderingContext2D | The context to draw this active tile 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.
Returns
This active tile's data.
- Type
- Object
move(direction, optionsopt)
Animate this active tile's position.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
direction |
string | The movement direction, either 'up', 'down', 'left', 'right'. |
|
options |
AnimationOptions |
<optional> |
An optional options 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 |