GetTileWidth
From Spheriki
Gets the width of tiles on the currently loaded map.
Contents |
Usage
- number is returned, which is the width of the tiles on the map.
Examples
To see the number of pixels wide a map is, we can use this function along with GetLayerWidth(), and plonk it in the corner of the screen. By multiplying the pixel width obtained with GetTileWidth() by the number of tiles on a layer obtained using GetLayerWidth(), we get the total pixel width of a map.
First, use the Sphere IDE to make a map of any kind. Even a blank map will do.
Then place this in a script file (say, main.js):
var font = GetSystemFont();
function game()
{
MapEngine("name_of_map.rmp", 60);
}
And place the following script in the map's render script (using the IDE):
var tile_width = GetTileWidth(); var tiles_wide = GetLayerWidth(0); font.drawText(0, 0, "Map pixel width: " + tiles_wide * tile_width);
When you run this, you will see the width of the map in pixels.
Notes
- The map engine needs to be running in order for this function to work.
- Since all tiles on a map are the same width, the number returned by this function will represent the pixel width of all tiles.
- For the pixel height of all tiles on a map, see GetTileHeight().