Sign in to follow this  
gamify

load layer

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

Share this post


Link to post
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

 

 

 

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.