import Rectangle from "../geom/Rectangle"; import Matrix from "../geom/Matrix"; import ColorTransform from "../geom/ColorTransform"; import Tileset from "./Tileset"; import TileContainer from "./TileContainer"; import Shader from "./Shader"; import BlendMode from "./BlendMode"; declare namespace openfl.display { /** * 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. * */ export class Tile { constructor(id?: number, x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, originX?: number, originY?: number); /** * 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. * */ get alpha(): number; set alpha(value: number) /** * 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. * */ get blendMode(): BlendMode; set blendMode(value: BlendMode) /** * A ColorTransform object containing values that universally adjust the * colors in the display object. * * This property is supported only when using hardware rendering. * */ get colorTransform(): ColorTransform; set colorTransform(value: ColorTransform) /** * An additional field for custom user-data * */ data: any; /** * Indicates the height of the tile, in pixels. The height is * calculated based on the bounds of the tile after local transformations. * When you set the `height` property, the `scaleY` property * is adjusted accordingly. * If a tile has a height of zero, no change is applied * */ get height(): number; set height(value: number) /** * The ID of the tile to draw from the Tileset * */ get id(): number; set id(value: number) /** * 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. * * @see [Using Matrix objects](https://books.openfl.org/openfl-developers-guide/working-with-geometry/using-matrix-objects.html) * */ get matrix(): Matrix; set matrix(value: Matrix) /** * Modifies the origin x coordinate for this tile, which is the center value * used when determining position, scale and rotation. * */ get originX(): number; set originX(value: number) /** * Modifies the origin y coordinate for this tile, which is the center value * used when determining position, scale and rotation. * */ get originY(): number; set originY(value: number) /** * 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. * */ parent: TileContainer; /** * The custom rectangle to draw from the Tileset * */ get rect(): Rectangle; set rect(value: Rectangle) /** * 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`. * */ get rotation(): number; set rotation(value: number) /** * 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. * */ get scaleX(): number; set scaleX(value: number) /** * 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. * */ get scaleY(): number; set scaleY(value: number) /** * Uses a custom Shader instance when rendering this tile. * * This property is only supported when using hardware rendering. * */ get shader(): Shader; set shader(value: Shader) /** * The Tileset that this Tile is rendered from. * * If `null`, this Tile will use the Tileset value of its parent. * */ get tileset(): Tileset; set tileset(value: Tileset) /** * Whether or not the tile object is visible. * */ get visible(): boolean; set visible(value: boolean) /** * Indicates the width of the tile, in pixels. The width is * calculated based on the bounds of the tile after local transformations. * When you set the `width` property, the `scaleX` property * is adjusted accordingly. * If a tile has a width of zero, no change is applied * */ get width(): number; set width(value: number) /** * 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. * */ get x(): number; set x(value: number) /** * 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. * */ get y(): number; set y(value: number) /** * Duplicates an instance of a Tile subclass. * * @return A new Tile object that is identical to the original. * */ clone(): Tile; /** * 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. * * @param targetCoordinateSpace The tile that works as a coordinate system. * @return Rectangle The bounding box. If no box found, this will return {0,0,0,0} rectangle instead of null. * */ getBounds(targetCoordinateSpace: Tile): Rectangle; /** * 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. * * @param obj The tile to test against. * @return `true` if the bounding boxes of the tiles * intersect; `false` if not. * */ hitTestTile(obj: Tile): boolean; /** * 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. * */ invalidate(): void; } } export default openfl.display.Tile;