Anything placeable on the map is housed in a Tile.
A Tile can hold a TilePic or an Entity inside of it.
When you use Entity::SetPos or Entity::SetBaseColor, internally, these functions are called.
The reason we use a Tile interface at times is that it lets us perform operations on an Entity or TilePic without knowing or caring what it really is.
Tile | Anything placeable on the map is housed in a Tile. |
Member Functions | |
GetType | |
SetPos | |
GetPos | |
SetLayerID | |
GetLayerID | |
SetBaseColor | |
GetBaseColor | |
GetAsEntity | |
Tile Related Constants | |
C_TILE_TYPE_CONSTANTS | Use with Tile::GetType to see what a Tile is actually housing inside. |
C_TILE_TYPE_BLANK | A blank/invalid tile. |
C_TILE_TYPE_PIC | This means the Tile houses a TilePic inside and <Tile::GetAsTilePic> is safe to use. |
C_TILE_TYPE_ENTITY | This means the Tile houses an Entity inside and Tile::GetAsEntity is safe to use. |
number GetType()
One of the C_TILE_TYPE_CONSTANTS. If it is a C_TILE_TYPE_ENTITY, you know you can use the GetAsEntity function safely.
nil SetLayerID(number layerID)
Allows you to change the layer of an entity.
Note that the actual movement will not happen until the end of that game logic cycle.
this:SetLayerID(this:GetLayerID()+1); //move up one layer
//Note, this may or may not affect our sorting level as expected, depends on the layer's settings.
number GetLayerID()
local layerID = this:GetLayerID();
LogMsg("We're on layer " .. layerID);
The layer ID that we’re on.
nil SetBaseColor(Color color);
Using this you can change the color of an entity/tilepic. Technically, you’re just setting how much of red, green, blue can get through.
So if you start with white, you can make any color by removing the colors you don’t want.
A Color object also contains an alpha value, this lets you set the translucency. (This happens on top of whatever per-pixel alpha the image already has)
myTile:SetBaseColor(Color(255,20,20,255)); //we should now look very red, since we're not
//letting much green or blue through.
//another example
Color c = Color(255,255,255,110); //full color, but only about half the alpha
myTile:SetBaseColor(c); //we're now about 50% invisible
color | A Color object. |
Entity GetAsEntity();
The Entity object interface inside the tile, or nil if this isn’t an entity.
C_TILE_TYPE_CONSTANTS | Use with Tile::GetType to see what a Tile is actually housing inside. |
C_TILE_TYPE_BLANK | A blank/invalid tile. |
C_TILE_TYPE_PIC | This means the Tile houses a TilePic inside and <Tile::GetAsTilePic> is safe to use. |
C_TILE_TYPE_ENTITY | This means the Tile houses an Entity inside and Tile::GetAsEntity is safe to use. |
Use with Tile::GetType to see what a Tile is actually housing inside.
This means the Tile houses an Entity inside and Tile::GetAsEntity is safe to use.