Jump to content

Tilemap - "Cannot read property 2 of undefined"


Will
 Share

Recommended Posts

Hey there

 

Been having some trouble with Phaser and rendering CSV tilemaps.

 

I have basically copied the code from the CSV example, in an attempt to get CSV rendering to actually work. Things work (kinda) well when the tile size is 32x32, if I change the tile size to 16x16 as soon as the game loads I get a "Cannot read property 2 of undefined" from line 50,363. I'm using Phaser 2.0.2. 

 

Also, the same problem happens when I scroll the camera to the far right of the map, same error thrown, even with tile size 32x32.

 

My tilemaps look like this - 

0, 1, 1, 1, 1, 1, 0,1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

But a whole lot bigger. Only contains zeros and ones, though the tileset has 4 tiles in it.

 

EDIT: Just tried Phaser 2.0.3, get the same error.

 

EDIT2:

 

I recoded most of it, hadn't done a lot. It then accepted 16x16 tiles fine, still threw the error when I scrolled right. Decided to use the assets from the example, and it all worked fine! Not sure why, but I'm gonna have a mess with my assets until this works... Is there an exact specification to what they have to be like?

Link to comment
Share on other sites

Ok, just making a new post so I can mark it as the answer.

 

When loading a tilemap from a CSV, phaser doesn't like having commas on the end of the line.

 

So

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 

Would throw an error, but

1, 1, 1, 1, 1, 11, 1, 1, 1, 1, 11, 1, 1, 1, 1, 1

Would not. :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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