Sign in to follow this  
Zenext

Tilemap get object position

Recommended Posts

Hi everyone,

 

Is there a way to get object like getTile method for tiles? I am making grid based game and i need to check if there are any objects on specific tile position.

 

Thanks in advance.

Share this post


Link to post
Share on other sites

you need add custom param for your object. And after by means methods .hasOwnProperty(your param) and method forEach get your object from object layer. 

this.map = this.add.tilemap('tilemap');

var objects = this.map.objects;

var myObj;

objects.forEach(function(el){

    if(el.hasOwnProperty(customParam) && el.customParam==customParamValue){

        myObj=el;

    }

})

Share this post


Link to post
Share on other sites

@jmp909 - no, not yet. No layers, just 128 128 generated tileMap data, I'm interested because I opened another post on tilemaps:

I am able to save files natively by full OS support with node modules via nwjs, but I have not found a way to save generated tilemaps with phaser into real files- because of the object structure:
http://www.html5gamedevs.com/topic/18787-save-tilemap-data-using-nwjs-phaserjs-and-node-fs-can-save-files-convert-tilemap-in-tiled-json-like-file/

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.