MapToScreenX
From Spheriki
Returns the screen X coordinate of a position on the map.
Contents |
[edit]
Usage
number MapToScreenX(layer, x);
- layer Number, non-negative. The layer of the map that the X coordinate to convert is on.
- x Number. The map X coordinate to change into a screen X coordinate.
- number is returned, which is the final screen X coordinate.
[edit]
Examples
One use of map-to-screen functions is to manually find the coordinates of persons on the map.
/** In a script file. */ const name = "bob"; var font = GetSystemFont();
/** In a render script. */ var layer = GetPersonLayer(name); var x = MapToScreenX(layer, GetPersonX(name)); var y = MapToScreenY(layer, GetPersonY(name)); // Adjust text position x -= font.getStringWidth(name); y += font.getHeight(); font.drawText(x, y, name);
The above example will draw the name of the person named "bob" on the map while the map engine is running.
[edit]
Notes
- This function only operates correctly while the map engine is running.
[edit]

