MapToScreenX

From Spheriki

Jump to: navigation, search

Returns the screen X coordinate of a position on the map.


Contents

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.


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.


Notes

  • This function only operates correctly while the map engine is running.


See also

Personal tools