Jump to content

How to make spine's onComplete event fires while losing tab focus?


Herbert
 Share

Recommended Posts

hi guys,

How can I make a spine keep checking onComplete Event while losing tab focus?
As I tested, if I run several spine animations(different length) at the same time, then switch to another tab immediately, 
the onComplete events won't fire, but they will fire at once when the tab get focus again.

Link to comment
Share on other sites

hi @ivan.popelyshev,

Thanks for your hints, I got it works by calling updateTransform of all spines in my custom setInterval which will keep firing on blur. something like

createSpine(data, opts) {
    const spine = new PIXI.spine.Spine(data, opts);
    this.updateList.push(spine);
    return spine;
}

updateOnBlur() {
     // update animatedSprite
     PIXI.ticker.shared.update();

     // update spine
     this.updateList.forEach(spine => spine.updateTransform());
}

I am wondering is there any setting that I can apply shared ticker to all spines, so I don't need to store them in an array.

Link to comment
Share on other sites

dont forget to remove them when its needed, or you'll get memory leak.

Well, you can just call updateTransform on whole stage and not list of spine objects, however you need a temporary parent for it (or get NullPointerException), like WebGLRenderer or CanvasRenderer does , please look inside pixi sources. Or you can call updateTransform of all direct children of the stage.

https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/webgl/WebGLRenderer.js#L309

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