htmlgivesmedepression Posted May 1, 2021 Share Posted May 1, 2021 Hello, I am experiencing a weird glitch in which spritesheets don't load properly sometimes (every 5th time?) and it shows up as just blue empty background. Here is my code: var frames = [] for (let i = 0; i < 48; i++) { frames.push("spritesheets/frame/" + (i+1) + ".png") } myApp.background = new PIXI.AnimatedSprite.fromFrames(frames); myApp.background.width = Constants.WIDTH; myApp.background.height = Constants.HEIGHT; myApp.background.x = myApp.renderer.renderer.width / 2 - Constants.WIDTH / 2; myApp.background.y = myApp.renderer.renderer.height / 2 - Constants.HEIGHT / 2; myApp.renderer.stage.addChild(myApp.background); myApp.background.animationSpeed = 0.125; myApp.background.play(); I hope you can help me! Quote Link to comment Share on other sites More sharing options...
Exca Posted May 6, 2021 Share Posted May 6, 2021 Can you check from your browser debuggers network tab that the frames are loaded when the playback fails? Quote Link to comment Share on other sites More sharing options...
Teckniel Posted May 6, 2021 Share Posted May 6, 2021 (edited) Think you have a cache related issue. Write some debugger handlers i guess and check the browser debugger like Exca said. Else i have no clue, pretty new the scene You use Pixi.Loader ? Edited May 6, 2021 by Teckniel Quote Link to comment Share on other sites More sharing options...
htmlgivesmedepression Posted May 6, 2021 Author Share Posted May 6, 2021 How would I go about checking if it loads? I don't use PIXI.Loader, the code is all there is, PIXI.AnimatedSprite.fromFrames loads it all for me. Would it be a better approach to use PIXI.Loader to load the frames individually? Quote Link to comment Share on other sites More sharing options...
Exca Posted May 7, 2021 Share Posted May 7, 2021 14 hours ago, htmlgivesmedepression said: How would I go about checking if it loads? I don't use PIXI.Loader, the code is all there is, PIXI.AnimatedSprite.fromFrames loads it all for me. Would it be a better approach to use PIXI.Loader to load the frames individually? You can check the network tab in browser debugger (f12) to see if the textures are visible there and with a result of 200 (http ok). Also using pixi loader is a good idea, as then the assets are already loaded when you are going to play the animation. Otherwise it might happen that images are still loading when the animation is about to play. Quote Link to comment Share on other sites More sharing options...
Teckniel Posted May 7, 2021 Share Posted May 7, 2021 On 5/6/2021 at 6:51 PM, htmlgivesmedepression said: How would I go about checking if it loads? I don't use PIXI.Loader, the code is all there is, PIXI.AnimatedSprite.fromFrames loads it all for me. Would it be a better approach to use PIXI.Loader to load the frames individually? Check documets for loader but it go somthing like this create a var that holds the loader. add you assets to the loader. hook the loader on event and set the boolean to true -> this.loader.onComplete.add(() => { this.assetsLoaded = true; console.log("Assets Loader State:" + this.assetsLoaded); }) and in you render function do while (this.assetsLoaded = false) return; 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.