davidwesst

Phaser CE | Phaser.Tilemap.objects property

Recommended Posts

Hello everyone,
 
I'm working on a small game using TypeScript, and I hit a compilation issue with the Phaser.Tilemap object. I was going to submit it as an issue to GitHub, but because I'm new here I wanted to error on the side of caution and make sure that this is actually an issue, as per the contribution guidelines. :)
 
According to the phaser.d.ts file, on [line 5057](https://github.com/photonstorm/phaser-ce/blob/master/typescript/phaser.d.ts#L5057), the objects project is supposed to be an any[]. When running my application, I can see that Phaser.Tilemap.objects is an Object, with another property called objects, which is an any[].
 
I have attached a screenshot of my code editor watch expressions that shows the issue I'm facing.
 
If we make the following change to the def file, it would resolve the issue. I have confirmed the change in my local repository, and everything appears to compile as expected.
        objects: {
            objects: any[];
        };

To generate the error, I am loading TILED_JSON map data and iterating through it to find a specific tile, as follows:

        let map: Phaser.Tilemap
        for(let o of map.objects.objects) {
            if(o.type === "start") {
                start = new Phaser.Point(o.x, o.y - map.tileHeight);
                break;
            }
        }

 

phaser-ce.png

Edited by davidwesst
Added reason for posting here, and fixed a sentence that wasn't clear.

Share this post


Link to post
Share on other sites

Caveat: I don't do TypeScript.

That doesn't look right to me, any[]... it's not an array, it's an object: https://github.com/photonstorm/phaser-ce/blob/0c9bef16b98095be79e866fbee778a78e24486c3/src/tilemap/TilemapParser.js#L172

Do you have an object layer in your map called "objects"? What happens if you change its name to "cats"? (change your code, too)

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

  • Recently Browsing   0 members

    No registered users viewing this page.