Jump to content

Problems with loading atlas


JeReT
 Share

Recommended Posts

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 null

and 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

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 .json

But this didn't helped (I restarted the server).

Link to comment
Share on other sites

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

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:8080

you can also try node's http-server

npm install -g http-serverhttp-server

I'm using also wamp while on windows - it has never happened before

Link to comment
Share on other sites

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

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

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

 Share

  • Recently Browsing   0 members

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