Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by alexandre

How do I retrieve a background map by name, i.e., the map that corresponds to a named layer in WM?

e.g., something like

// inside ig.Game
this.getMap(<WM layer name>);

Thanks in advance

1 decade ago by Arantor

Iterate through the main game object's backgroundMaps array, in each element there will be a data property, inside that should be a name property.

What exactly are you hoping to achieve by getting an individual map?

1 decade ago by alexandre

Curious. I thought the data property only held the cell indices. Will check again.

Needed in my case for identification/retrieval purposes; I may want to have collapsible panels (HUD, messages, ads) at some point, the dynamic retrieval of which would spare me state (myHud, myMessagePanel, etc.) management.

1 decade ago by Arantor

My bad, it does only hold the data. I was looking through the combinations of game.js, background-map.js and map.js and got confused.

What you'd need to do, then, is roll your own loadLevel function, duplicating the one in game.js but just after newMap is created, add ld.name to newMap, then you can iterate over ig.game's backgroundMaps and find it that way.

1 decade ago by alexandre

Yep. Seems like. Nothing to it. What would have been nicer would have been for WM to offer the same property/value inputs setup that it does for the Entities layer. That would add a further level of flexibility.

1 decade ago by Arantor

It's not just that though in WM, you do also have to have it set up so that those values are pulled somewhere and stored where they can be accessed by the main game code.

I've done it in the past where I added custom values to layers but the custom value was something that would apply to every layer (making tile sizes non-square) and the consequence was that I had to manually receive the value in the map loader.
Page 1 of 1
« first « previous next › last »