Jump to content

Tiled in Phaser: When loading a tilemap, "create()" is no longer called.


karyann
 Share

Recommended Posts

First I want to say thank you for this forum and community, you all have already helped me a lot  :) However, this time I couldn't find an answer.

 

 

So, my issue is the following: I exported a map from Tiled. However, when I add the json file in preload(), my create() function stops being called altogether. I get absolutely nothing in the Chrome console, and my screen only stays black.

 

Here is my preload code inside my game.js:

preload: function(){this.load.image('sky', 'img/sky.png');this.load.image('ground', 'img/platform.png');this.load.image('star', 'img/star.png');this.load.spritesheet('dude', 'img/dude.png', 32, 48);this.load.tilemap('outsideJson', '../img/tilemaps/map1.json', null, Phaser.Tilemap.TILED_JSON);this.load.image('outside_tiles', '../img/tilemaps/outside_spritesheet3_small.png');},

As far as I could find, this should be the right syntax. I think my filepaths are good, since my folder structure is the following:

 -www   |_js      |_game.js   |_img      |_tilemaps         |_maps1.json         |_outside_spritesheet3_small.png

When I comment out the two lines loading the tilemap and spritesheet, the create() function works normally. However, when I leave the two lines, I put a console.log at the start of create() and it is never called. I have tried a lot of things and am out of clues now.

 

 

Thanks for your help!

Link to comment
Share on other sites

that's a strange one... does the JSON have anything funny in it?  

I don't think so, but I'm not sure if I'm looking for the right thing. Here is the whole json file: http://pastebin.com/HGUReTr8

 

Edit: Oh damn, I just saw that the "image" path is very weird... 

"image":"..\/..\/Desktop\/outside_spritesheet3_small.png",

I'll try changing it and test again.

 

Edit2: I just changed the path to the right folder (i.e not on desktop), but I still have the same result in the end. I guess I would have run into trouble eventually though, so at least that's fixed in advance.

 

 

 

Why are the paths for the images "img/sky.png" but the tilemap is "../img/tilemaps/map1.json"? Notice the ".." there?

 

What does the developer console say?

Ah, oops, I changed that for testing purposes before posting, and forgot to change it back before copy/pasting... There is absolutely nothing in the console, with or without "..". Seeing as the images work without the dots, the Json should too.

Link to comment
Share on other sites

Try keeping the console open and reloading the page? It's weird that nothing shows up at all. Maybe the JS is having trouble loading?

 

I did multiple times, and I tried on both my browser (chrome and firefox) and with DebugGap (a debugging application for PhoneGap, used with my Nexus 5). Both stay hopelessly empty, which is indeed very confusing. I do get console logs if I comment out the line where I load the json file, though.  :huh:

Link to comment
Share on other sites

Might be time to post the JSON of the map. I'm not sure what else could be going on.

 

Anything else going on in your state?

 

I posted it a bit higher, here's the link : http://pastebin.com/HGUReTr8 

When posting it yesterday, I saw that the image link was pointing to my desktop, so I changed it to the right folder but it still doesn't work.

 

As for the state, my first post is the whole preload function. There is some code inside the create function, but I doubt it would be of any help since create() isn't called. But just in case, here it is: http://pastebin.com/WMSwMSbL

When my application starts, I have a Menu state, which works fine.

 

The thing is, the tilemap actually worked at first, then I went on to make a store in another state, and when I came back to the game state it had stopped working though I didn't change anything in that file. After thinking back on the problem, I think I updated my Android SDK midway, and I don't know what else I may have done that could have interfered. 

 

Thank you for your help troubleshooting, by the way! I really appreciate it.

Link to comment
Share on other sites

After removing everything in the game but the menu and game states and the tilemap loading, everything works fine. It seems like trouble may be with my in-app billing plugin integration. Each part works perfectly on its own, bow somehow when put together the JSON doesn't want to load... I'll inverstigate further and post what I can find.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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