The Tile class is the base class for all objects that can be contained in a ITileContainer object. Use the Tilemap or TileContainer class to arrange the tile objects in the tile list. Tilemap or TileContainer objects can contain tile' objects, while other the Tile class is a "leaf" node that have only parents and siblings, no children.

The Tile class supports basic functionality like the x and y position of an tile, as well as more advanced properties of a tile such as its transformation matrix.

Tile objects render from a Tileset using either an id or a rect value, to reference either an existing rectangle within the Tileset, or a custom rectangle.

Tile objects cannot be rendered on their own. In order to display a Tile object, it should be contained within a Tilemap instance.

Constructor

new (id:Int = 0, x:Float = 0, y:Float = 0, scaleX:Float = 1, scaleY:Float = 1, rotation:Float = 0, originX:Float = 0, originY:Float = 0)

Variables

alpha:Float

Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). The default value is 1. Tile objects with alpha set to 0 are active, even though they are invisible.

blendMode:BlendMode

A value from the BlendMode class that specifies which blend mode to use.

This property is supported only when using hardware rendering or the Flash target.

colorTransform:ColorTransform

A ColorTransform object containing values that universally adjust the colors in the display object.

This property is supported only when using hardware rendering.

data:Dynamic

An additional field for custom user-data

id:Int

The ID of the tile to draw from the Tileset

matrix:Matrix

A Matrix object containing values that alter the scaling, rotation, and translation of the tile object.

If the matrix property is set to a value (not null), the x, y, scaleX, scaleY and the rotation values will be overwritten.

originX:Float

Modifies the origin x coordinate for this tile, which is the center value used when determining position, scale and rotation.

originY:Float

Modifies the origin y coordinate for this tile, which is the center value used when determining position, scale and rotation.

read onlyparent:TileContainer

Indicates the ITileContainer object that contains this display object. Use the parent property to specify a relative path to tile objects that are above the current tile object in the tile list hierarchy.

rect:Rectangle

The custom rectangle to draw from the Tileset

rotation:Float

Indicates the rotation of the Tile instance, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement tile.rotation = 450 is the same as tile.rotation = 90.

scaleX:Float

Indicates the horizontal scale (percentage) of the object as applied from the origin point. The default origin point is (0,0). 1.0 equals 100% scale.

Scaling the local coordinate system changes the x and y property values, which are defined in whole pixels.

scaleY:Float

Indicates the vertical scale (percentage) of an object as applied from the origin point of the object. The default origin point is (0,0). 1.0 is 100% scale.

Scaling the local coordinate system changes the x and y property values, which are defined in whole pixels.

shader:Shader

Uses a custom Shader instance when rendering this tile.

This property is only supported when using hardware rendering.

tileset:Tileset

The Tileset that this Tile is rendered from.

If null, this Tile will use the Tileset value of its parent.

visible:Bool

Whether or not the tile object is visible.

x:Float

Indicates the x coordinate of the Tile instance relative to the local coordinates of the parent ITileContainer. If the object is inside a TileContainer that has transformations, it is in the local coordinate system of the enclosing TileContainer. Thus, for a TileContainer rotated 90° counterclockwise, the TileContainer's children inherit a coordinate system that is rotated 90° counterclockwise. The object's coordinates refer to the registration point position.

y:Float

Indicates the y coordinate of the Tile instance relative to the local coordinates of the parent ITileContainer. If the object is inside a TileContainer that has transformations, it is in the local coordinate system of the enclosing TileContainer. Thus, for a TileContainer rotated 90° counterclockwise, the TileContainer's children inherit a coordinate system that is rotated 90° counterclockwise. The object's coordinates refer to the registration point position.

Methods

clone ():Tile

Duplicates an instance of a Tile subclass.

Returns:

A new Tile object that is identical to the original.

getBounds (targetCoordinateSpace:Tile):Rectangle

Gets you the bounding box of the Tile. It will find a tileset to know the original rect Then it will apply all the transformations from his parent.

Parameters:

targetCoordinateSpace

The tile that works as a coordinate system.

Returns:

Rectangle The bounding box. If no box found, this will return {0,0,0,0} rectangle instead of null.

hitTestTile (obj:Tile):Bool

Evaluates the bounding box of the tile to see if it overlaps or intersects with the bounding box of the obj tile. Both tiles must be under the same Tilemap for this to work.

Parameters:

obj

The tile to test against.

Returns:

true if the bounding boxes of the tiles intersect; false if not.

invalidate ():Void

Calling the invalidate() method signals to have the current tile redrawn the next time the tile object is eligible to be rendered.

Invalidation is handled automatically, but in some cases it is necessary to trigger it manually, such as changing the parameters of a Shader instance attached to this tile.