RyanPridgeon Posted November 20, 2014 Share Posted November 20, 2014 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? Quote Link to comment Share on other sites More sharing options...
dirkk0 Posted November 20, 2014 Share Posted November 20, 2014 Without the code it's hard to tell, but these problems almost always stem from synchronicity problems while loading (i.e. things are not loaded in the right order or at all). If this is the case, you want to make sure that you right the appropriate order in the 'loaded successfully' callbacks. Quote Link to comment Share on other sites More sharing options...
RyanPridgeon Posted November 20, 2014 Author Share Posted November 20, 2014 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.