JeReT Posted April 30, 2015 Share Posted April 30, 2015 Hi, I have a problem with loading an atlas in my preload method of a state.here is my code to load it (TypeScript):this.game.load.atlas('atlas', 'atlas.png', 'atlas.json');Here is the error messages I receive when testing:"Phaser.Loader - textureatlas[atlas]: JSON.parse: unexpected character at line 1 column 1 of the JSON data""Texture with key 'atlas' not found."TypeError: this._frameData is nulland here you can view my atlas.json file. The json file is without BOM. What is the Problem with it? Link to comment Share on other sites More sharing options...
rich Posted April 30, 2015 Share Posted April 30, 2015 Run it through an online JSON parser to check it. The error being thrown is coming from the JSON.parse JavaScript function itself, saying it's unable to parse the file. Fix that and the rest will work. Link to comment Share on other sites More sharing options...
JeReT Posted April 30, 2015 Author Share Posted April 30, 2015 It turned out that the json file couldn't be found on my local server. I somehow have to enable JSON as a content type or something. I am a noob with all this web stuff and feel a little bit lost I am using WAMP for local hosting.I already tried to change the httpd.conf of apache by adding the following line in the "<IfModule mime_module>" section:AddType application/json .jsonBut this didn't helped (I restarted the server). Link to comment Share on other sites More sharing options...
rich Posted April 30, 2015 Share Posted April 30, 2015 Hmm strange, I use WAMP as well and have never configured it to serve JSON files before. How about one of the atlases from the official phaser examples? Do they work? Link to comment Share on other sites More sharing options...
JeReT Posted April 30, 2015 Author Share Posted April 30, 2015 I copied the "explode" png and json file to the root of my project (where the index.html is located) and tried to load it:same result. while all png files can be loaded, I get a 404.3 error for the json files. So it seems to be some "json protection" behaviour of wamp. Link to comment Share on other sites More sharing options...
stauzs Posted April 30, 2015 Share Posted April 30, 2015 to test if that is server configuration fault or not - you can test on very simple server for quick tests I'm using php dev server:from cmd#if php is in the pathphp -S 127.0.0.1:8080orC:\wampp\path\to\php.exe -S 127.0.0.1:8080you can also try node's http-servernpm install -g http-serverhttp-serverI'm using also wamp while on windows - it has never happened before Link to comment Share on other sites More sharing options...
JeReT Posted April 30, 2015 Author Share Posted April 30, 2015 Hi stauzs, thanks for your answer.But I don't get how I can retrieve any further information with this... Link to comment Share on other sites More sharing options...
qdrj Posted April 30, 2015 Share Posted April 30, 2015 Hey @JeReT, It can be a problem with JSON file encoding. Try to convert your file to UTF-8. This tool can help - http://www.rotatingscrew.com/utfcast-express.aspx Link to comment Share on other sites More sharing options...
JeReT Posted April 30, 2015 Author Share Posted April 30, 2015 Hi qdrj, Thanks for the suggestion. But this is definately not the problem. I now installed io.js but I have the same problem...Not sure if I set it up correctly however. But if I did, it probably caused by something different than the server... Link to comment Share on other sites More sharing options...
JeReT Posted May 7, 2015 Author Share Posted May 7, 2015 I still have this problem...But i figured ou something: I use the integrated server of Visual Studio (IIS-8). Could somebody check out if the problem is my configuration or if it is a problem of type script with phaser?Here is a Visual Studio project with my problem:http://www.filedropper.com/circlepong would be really nice, if somebody could test this for me Link to comment Share on other sites More sharing options...
rich Posted May 7, 2015 Share Posted May 7, 2015 Just install a local / free web server and test it there? Or upload it to some web space or dropbox. Both will confirm what you need to know. Link to comment Share on other sites More sharing options...
stupot Posted May 7, 2015 Share Posted May 7, 2015 JeReT, you have to set the mime type for .json files when using IIS to serve Visual Studio web projects. In your web.config add this to the 'staticContent' section: <mimeMap fileExtension=".json" mimeType="application/json" /> Link to comment Share on other sites More sharing options...
Recommended Posts