65 getObjectLayer - JcerelusDev/CanvasGameJs GitHub Wiki

getObjectLayer

That method is used to get a specific tile object for a specific use. For example if your game has ladders and you want to detect when the player is colliding with any ladder of the level, instead of doing all the algorithm yourself, that reusable method is there to remove that pain from you.

How to use it ?

getObjectLayer(layerName)

Example :

var ladders = new game.getObjectLayer("ladder")
for(const ladder of ladders){
  if(isCollide(player,ladder)){
       do something ...
    }

}