Hide Map Objects
A module that draws its own scene in the map world (a battle board, a cutscene, a minigame) often needs the other characters of the map out of the way: the events, and in an MMORPG the other players.engine.hideMapObjects() hides them
for this client only.
What is hidden
Only the drawing of the objects: their sprite, name, sprite components, attached GUIs and lighting shadow. A hidden object no longer receives the pointer. Everything else keeps running:- the objects stay on the map and keep being synchronized (position, state, collisions);
- the camera follow and the
onActionof the events are not affected; - the server and the other players see no change.
Choosing the objects
Each kind takestrue (all of them), a list of ids, or a function that tests the
object. players also accepts 'others', every player but the local one.
Objects that come later, and several calls
Objects that enter the map after the call (a new event, a player who joins) follow the same filter until it is restored. Calls compose. An object is shown again once no remaining call hides it, so a cutscene can hide the merchant during a battle and both can end in any order. Calling a restore function a second time does nothing. The filters are dropped when the client changes map.Drawing a marker for a hidden object
engine.isMapObjectHidden(id) tells whether an object is hidden. It is reactive
inside CanvasEngine computations, so a module can draw its own marker in place of
the hidden sprite:
Client and server
To change how an object looks for everyone, change it on the server instead, for
example with
player.setGraphic().
See hideMapObjects in the
client API reference.