MapEngine
From Spheriki
Starts the Sphere map engine with the given map, and at the given speed.
Contents |
[edit]
Usage
MapEngine(map, fps);
- map String. Filename of the map to start with.
- fps Number, positive. The frames per second, or speed that the map engine should run at. Sixty (60) is the value typically used for this parameter.
[edit]
Examples
The following example is from sphere/docs/sphere_tutorial.txt. The spriteset "aegis.rss" and the map "field.rmp" must already exist (or be created) for the following code snippet to work.
CreatePerson("aegis", "aegis.rss", false);
AttachInput("aegis");
AttachCamera("aegis");
MapEngine("field.rmp", 60);
In order from top to bottom:
- Creates a person named "aegis" that uses the "aegis.rss" spriteset, and persists between map changes.
- Lets the player move "aegis" using the arrow keys.
- Makes the camera keep its focus on "aegis".
- Starts the map engine with the map "field.rmp", running at a speed of 60 frames per second.
[edit]
Notes
- The map engine is one of Sphere's most powerful features. It provides an environment which supports multi-layer maps, player movement and input, parallax scrolling, reflective layers, map- and person-based events, queued scripts, delayed scripts, amongst others.
- Any code that occurs after a call to MapEngine() will not be executed until the map engine is ended, using the ExitMapEngine() function. If the map engine is ended with Exit() or Abort(), the code will not be executed at all. This is a common error to those new to Sphere.
[edit]
See also
- CallDefaultMapScript()
- CallMapScript()
- ChangeMap()
- GetCurrentMap()
- GetMapEngineFrameRate()
- IsMapEngineRunning()
- SetDefaultMapScript()
- SetMapEngineFrameRate()
- UpdateMapEngine()
- Abort()
- AttachCamera()
- AttachInput()
- CreatePerson()
- Exit()

