Jump to content

Problems loading graphics.


RyanPridgeon
 Share

Recommended Posts

In my game, I have 3 spritesheets being loaded, "soldierred.png", "soldierblue.png", and "tiles.png".

 

More than 19 times out of 20, these load correctly using SpriteSheetLoader's. I have on my screen a tilemap constructed using "tiles.png", and then 3 soldier sprites, 2 of which are "soldierblue.png" and one of which is "soldierred.png".

 

However, occasionally, for some reason it only shows 3 soldierblue's, or 3 soldierred's, instead of the 2 soldierblue and 1 soldierred. tiles.png always displays correctly. I've done some printouts where the sprites are being created and when the spritesheets send their 'loaded' event, and they definitely use the correct names.

 

I do get a "json not well formed" error in the console when this happens, but it's on every spritesheet's json file, for the line;

{"frames": {

However, none of these problems occur most of the time when the game is loaded. There doesn't seem to be any surefire way to make the error happen, I've just had to leave some debug prints in the console and wait for next time it comes around.

 

Does anyone know why this is happening?

Link to comment
Share on other sites

Realised that the frames in soldierred had the same names as soldierblue, since I just copied the json and changed the colour of the spritesheet's image. I guess it was fighting over identical frame names. Since changing this to give them different frame names, the all-blue and all-red soldier problem has gone.

 

I still get the json "not well formed" errors in FIrefox (not in Chrome). But I guess this is nothing to worry about?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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