Jump to content

Unable to preload spritesheets animation with PIXI.Prepare.


KreNtal
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

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