Jump to content

Lag on the first play when swapping animation using onComplete callback in PIXI animatedSprite from two spritesheets


ravinesstream
 Share

Recommended Posts

I've loaded two animations in Pixi with spritesheets. I wanna swap to second animation right after the first animation is finished.

Quote
animation0.onComplete = function() { // animation0 and animation1 are two animatedSprite while animation0.loop = false and animation1.loop = true
    animation0.renderable = false;
    animation1.gotoAndPlay(0);
    animation1.x = 100;
    animation1.y = 100;
    animation1.renderable = true; 
}

However, (It's happen with a 3840x1080 resolution, and the GPU memory usage is mainly fall between 90%-99%)

1. there's a significant lag of the transition between these two animations in the first time.

2. After the first play, if I remove and add the animatedSprite from the stage immediately, the transition is very smooth.  

3. After the first play, If I remove the 2 animatedSprite from the stage, wait for ~2-3 minutes and add the 2 animatedSprite into the stage again, the transition is lagging again.

I wanna know the proper way of swapping two animation in Pixi and also the reason of this phenomenon.

Link to comment
Share on other sites

Texture upload to videomemory lags. 

After 2-3 minutes of not drawing particular texture, pixi GC unloads it. Use `prepare` plugin and turn off the Gc.

http://pixijs.download/dev/docs/PIXI.prepare.html

http://pixijs.download/dev/docs/PIXI.settings.html#.GC_MODE

https://github.com/pixijs/pixi.js/blob/v4.x/src/core/renderers/webgl/TextureGarbageCollector.js

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