KreNtal Posted November 22, 2022 Share Posted November 22, 2022 I'm working on a slot machine and I created some symbol animations in a spritesheet with texture packer. When the slot is spinning I need to instantiate the AnimatedSprite on the fly because only the latest symbols will be animated while the rest are just normal sprites. Everything is working as expected, the only problem is that on the first 3-4 spins the slot is lagging at the end, when the AnimatedSprite are instantiated all together. After that I guess they're all loaded into gpu memory and everything is going smoothly. I tried to preloading them with PIXI.Prepare plugin but it does not work as expected. Maybe my syntax is wrong, I don't know. Can someone point me in the right direction? How can i preload them in the GPU memory if they're not present in the app.stage at start? Quote Link to comment Share on other sites More sharing options...
Alexander Kolosov Posted November 25, 2022 Share Posted November 25, 2022 Maybe you should try creating an instance of PIXI.AnimatedSprite in advance? something like a pool.Do you load spritesheet in advance? or when is it necessary? can you show me a code snippet? Quote Link to comment Share on other sites More sharing options...
KreNtal Posted November 25, 2022 Author Share Posted November 25, 2022 Thanks for answering. Actually I had some improvements loading an AnimatedSprite with just one single texture and then swapping it at the end with the real animation, but still I experience some lag on first 2-3 spins. Loading AnimatedSprite with a single texture: const element = [SlotManager.getInstance().reelsMatrix[i][this.reels[i].currentIndex].blurredTexture]; symbolSprite = new AnimatedSprite(element); Swapping it at the end: symbol.textures = SlotManager.getInstance().reelsMatrix[index][length + j].animation; Sorry, I cannot publish to much of the code. Quote Link to comment Share on other sites More sharing options...
Alexander Kolosov Posted November 28, 2022 Share Posted November 28, 2022 Sorry for delay. Hmm, its seems good. Have you tried to build something test without extra logic? just running the animation in the spins without any logic. AnimatedSprite should not be too heavy. Quote Link to comment Share on other sites More sharing options...
KreNtal Posted November 29, 2022 Author Share Posted November 29, 2022 Not really. I will and let you know. However I got big improvements with the method mentioned before. Still thinking that preparing it before could help but I had no luck on making it works. 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.