Methods
Introduction
Functions pertaining to Map’s tile effects, object upload, and other convenient feature functions for maps are provided below.
putTileEffect
Function to apply a tile effect to the specified coordinates
putObject
Function to place an object on the specified coordinates
putObjectMultiple
Function to install objects at once by entering coordinates to place objects in a two-dimensional array.
putObjectWithKey
Function to place an object with a key value on the specified coordinates
playObjectAnimation
Function to execute an object’s sprite animation on the specified coordinates
playObjectAnimationWithKey
Function to execute an object's sprite animation whose key value matches
moveObject
Function to move an object from one x and y axis coordinates to another x and y axis coordinates during an X amount of time
moveObjectWithKey
Function to move an object with a key value to the specified coordinates
clearAllObjects
Function to remove all objects created using ZEP script
getTile
Function to return the enum value of the tile at the x and y coordinates of the corresponding layer
hasLocation
Function to check if the corresponding location exists in the map and return true or false
getObjectsByType
Function to return the objects that correspond to Type
getTopObjectsByType
Function to return the top objects that correspond to Type
sayObjectWithKey
Function to display a word balloon above an object with a key value
📚 API Explanation and Example
Methods at a Glance
putTileEffect
Map.putTileEffect(x: number, y: number, tileID: TileEffectType)
This function applies a tile effect to the specified coordinates.
Parameters
More information on TileEffectType can be found on the Tile Effect Type Detailed Explanation page.
x, y
Number
Object’s x and y coordinates
tileID
TileEffectType
• TileEffectType.NONE: no effect •TileEffectType.IMPASSABLE: players cannot pass • TileEffectType.SPAWN: players spawn here • TileEffectType.PORTAL: move players to a different location •TileEffectType.PRIVATE_AREA: designates a private discussion area •TileEffectType.SPOTLIGHT: designates a spotlight area • TileEffectType.EMBED: adds a web link • TileEffectType.LOCATION: designated area for ZEP script •TileEffectType.AMBIENT_SOUND: sets background sounds •TileEffectType.TILE_EMBED: embeds something from the web •TileEffectType.WEB_PORTAL: a web portal •TileEffectType.SPACE_PORTAL: a portal to another Space
Example
Set up an IMPASSABLE tile effect.
putObject
Map.putObject(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
To better understand ScriptDynamicResource, please refer to the Understanding Sprite Sheets page.
You can delete the object installed from script by sending the null value to parameter.
Parameters
x, y
Number
x, y coordinates of where the tile effect will be applied
dynamicResource
ScriptDynamicResource
Variable name of the saved sprite.
loop
Number
Specify the number of times to repeat the animation
option
Object
Input { overlap: true } in the parameter field to recognize the object from App EventListener such as onObjectTouched and onObjectAttacked.
Example
Create the blueman object.
putObjectMultiple
Map.putObjectMultiple(tileArray: array, type: PutObjectType, dynamicResource: ScriptDynamicResource, option: object);
This function installs objects at once by entering coordinates to place objects in a two-dimensional array. This allows you to reduce the load when you install many objects at once.
Parameters
tileArray
Array
Enter a two-dimensional array defining the coordinates where you want to place the objects. (Maximum length limited to 10)
type
PutObjectType
PutObjectType.STROKE
Once a path is created by connecting the coordinates defined in the tileArray array in order, objects are placed in all coordinates along the created path.
dynamicResource
ScriptDynamicResource
Image resources loaded using App.loadSpriteSheet
option
Object
In order for App EventListener to recognize an object, such as onObjectTouched and onObjectAttached, you should enter {overlap:true}
in the parameter box.
Example
Place objects in a square or circle.
putObjectWithKey
Map.putObjectWithKey(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
This function places an object on the specified coordinates (Reference coordinates: Left-Top)
Parameters
x, y
Number
x, y coordinates of where the object will be placed
dynamicResource
ScriptDynamicResource
Variable name of the saved sprite.
option
Object
Sets the attributes including key values, moveSpeed, overlap, useDirAnim etc.
Example
Create the blueman object with a key value.
getObjectWithKey
Map.getObjectWithKey(key: String)
This function gets the information of the object with the corresponding key value.
Parameter
key
String
The key value of the object to get information from
Example
Create an object with a key value and display the related data.
playObjectAnimation
Map.playObjectAnimation(x: number, y: number, name: string)
This function activates the object animation at the corresponding coordinates.
The above function must be preceded by the Map.putObject function.
Check the Understanding Sprite Sheets page if it’s your first time hearing about sprite sheets.
Parameters
x, y
Number
x, y coordinates of where the tile effect will be applied
name
String
let variable = App.loadSpritesheet(...)
The saved variable name of the sprite must be inputted as below:
→ ‘#’ + variable.id
Example
Set up a dancing blueman object.
playObjectAnimationWithKey
Map.playObjectAnimation(key: string, animName: string, repeatCount: number)
This function executes the object's sprite animation whose key value matches.
The Map.putObjectWithKey
function must preceed this function.
If you are not familiar with sprite images, please refer to the Understanding Sprite Sheets page!
Parameters
key
String
The key value of the object
animName
String
The name of the animation to play
repeatCount
Number
Specify the number of times to repeat the animation ("-1" means infinite.)
Example
Set up a dancing blueman object.
moveObject
Map.moveObject(x: number, y: number, targetX: number, targetY: number, time: number)
This function moves the object from the object’s x and y coordinates to the target x and y coordinates for a certain amount of time (secs).
The above function must be preceded by the Map.putObject function.
Check the Understanding Sprite Sheets page if it’s your first time hearing about sprite sheets.
Parameters
x, y
Number
Object’s x and y coordinates
targetX, targetY
Number
Target location’s x and y coordinates
time
Number
Time(seconds) to reach the target location.
Example
Move the blueman object.
moveObjectWithKey
Map.moveObjectWithKey(key: string, targetX: number, targetY: number, path:boolean = true)
This function moves an object with a key value to the specified coordinates.
💡 When "path" is "true", the object doesn't move when the target location is an impassable tile or unreachable.
Parameters
key
String
Object's key value
targetX, targetY
Number
Target location’s x and y coordinates
path
Boolean
true: cannot pass an impassable tile false: can pass an impassable tile
Example
How moveObjectWithKey
works
clearAllObjects()
Map.clearAllObjects()
This function removes all objects created by the ZEP script.
Parameter
None
Example
Remove all created objects.
getTile
Map.getTile(layer: number, x: number, y: number)
Return the type value of the tile at the x and y coordinates of the corresponding layer. If no tile, returns "-1."
Parameters
layer
Number
Values corresponding to the layer 0 = Floor (floor tile), 1 = WALL (wall tile), 2 = TileEffect (tile effects), 3 = Object (objects), 5 = TopObject (top objects),
x, y
Number
X and Y coordinates
Example
Check the types of all objects in the map.
hasLocation
Map.hasLocation(locationName: String)
This function checks if the corresponding location exists in the map and returns true or false accordingly.
Parameter
locationName
String
Name of the location
Example
Create a function that checks if the location is installed.
getObjectsByType
Map.getObjectsByType(type: numer) : array
This function returns the objects that correspond to Type.
Parameter
type
Number
Type value of the object
Example
Check all type of objects.
getTopObjectsByType
Map.getTopObjectsByType(type: numer) : array
This function returns the top objects that correspond to each type.
Parameter
type
Number
Type value of the object
Example
Check all types of top objects.
sayObjectWithKey
Map.sayObjectWithKey( key: string, message: string )
This function displays a word balloon above an object with a key value.
Parameters
key
String
The key value of the object
message
String
Message to display in a word balloon
Example
Display a word balloon above an object with a key value.
Appendix
Last updated