Scenes > World


Gravity

Get Value of Gravity

horizontal gravity

Returns the value of the Horizontal (X) or Vertical (Y) components of gravity. Gravity is a force that is applied to all actors (that are affected by it).

getGravity().x
getGravity().y

Set Gravity

set gravity to x dir number y dir number

Sets the world's gravity.

setGravity([NUMBER], [NUMBER]);

Properties

Scene Width / Height

scene width pixels

Returns the current scene's [width/height] in [pixels/tiles].

getSceneWidth()
getSceneHeight()
Std.int(getSceneWidth()/getTileWidth())
Std.int(getSceneHeight()/getTileHeight())

Scene Name

scene name

Returns the current scene's name.

getCurrentSceneName()

Tile API

Tile Width / Height

tile width

Returns the current scene's tile width/height.

getTileWidth()
getTileHeight()

Convert to Tile Coordinates

get column x coordinate of number in scene

Converts a coordinate from pixels (real location) to tiles. In other words, divides the coordinate by the tile width or height respectively.

getTilePosition(0, [NUMBER]) //x coordinate
getTilePosition(1, [NUMBER]) //y coordinate

Set a Tile

set tile at row int col int layer id object using tile id int from tileset id int

Sets a tile at the given position and layer.

setTileAt([INT], [INT], engine.getLayerById([INT]), [INT], [INT]);
setTileAt([INT], [INT], engine.getLayerByName([TEXT]), [INT], [INT]);

Does a Tile exist at location?

tile exists at row int col int layer id object

Returns true if any tile exists at the given position and layer.

tileExistsAt([INT], [INT], engine.getLayerById([INT]))
tileExistsAt([INT], [INT], engine.getLayerByName([TEXT]))

Get ID for Tile at location

id for tile at row int col int layer id object

Returns the ID of the tile at the given position and layer, or -1 if no tile found.

getTileIDAt([INT], [INT], engine.getLayerById([INT]))
getTileIDAt([INT], [INT], engine.getLayerByName([TEXT]))

Does a solid tile exist at location?

tile collision shape found at row int col int layer id object

Returns true if ANY collision shape exists. If layer ID is -1, loops through all layers.

tileCollisionAt([INT], [INT], engine.getLayerById([INT]))
tileCollisionAt([INT], [INT], engine.getLayerByName([TEXT]))

Get Collision ID for tile at location

collision id for tile at row int col int layer id object

Returns the ID of the collision shape for the tile at this position and layer, or -1 if no tile found.

getTileColIDAt([INT], [INT], engine.getLayerById([INT]))
getTileColIDAt([INT], [INT], engine.getLayerByName([TEXT]))

Get Tileset ID for tile at location

id for tile's tileset at row int col int layer id object

Returns the ID of the tileset for the tile at this position and layer, or -1 if no tile found.

getTilesetIDAt([INT], [INT], engine.getLayerById([INT]))
getTilesetIDAt([INT], [INT], engine.getLayerByName([TEXT]))

Remove tile at location

remove tile at row int col int layer id object

Remove the tile at this position.

removeTileAt([INT], [INT], engine.getLayerById([INT]));
removeTileAt([INT], [INT], engine.getLayerByName([TEXT]));

Get Metadata for tile at location

data for tile at row int col int layer id object

Get the tile data for the tile at this position. Returns empty text if no tile found.

getTileDataAt([INT], [INT], engine.getLayerById([INT]))
getTileDataAt([INT], [INT], engine.getLayerByName([TEXT]))