Jump to content

gamify
 Share

Recommended Posts

hello how to retrieve the layer object 

me.game.currentLevel.getLayerByName("background");

throwing error : Uncaught TypeError: Cannot read property 'getLayerByName' of undefined
    at <anonymous>:1:21

So can anyone help me  to get the layer 

me.game.getEntityByName("mainPlayer")[0];

also throwing error : Uncaught TypeError: me.game.getEntityByName is not a function
    at <anonymous>:1:9

for melonJS Game Engine v4.1.0

Link to comment
Share on other sites

me.game.world.getChildByName("background")[0] is working but how to get the 

but how to get

tile.row and tile.col

of the above layer

 

i want particular layer tile row and col but not full game layer???? please can anyone help

 

 

 

 

Link to comment
Share on other sites

once you get a reference to the layer you want, you can get the tile information by using the getTile function :

http://melonjs.github.io/melonJS/docs/me.TMXLayer.html#getTile

here is an example here, where we use this to highlight the tile under the mouse pointer :

https://github.com/melonjs/melonJS/blob/master/examples/isometric_rpg/js/screens/play.js#L46

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...