Jump to content

How to change Spine Data in pixi-spine? fast and recommended


JayCabasag
 Share

Recommended Posts

Hi, I'm new to PIXI JS and pixi spine, I'm wondering if there is a way for me to make it more performant in terms of changing the spine data. What we currently have is adding the spine and removing it from its parent. But this is an expensive process for our game. Is there a better way to do it? Here is the sample code where I want to change the spine data.

 

    /**
     * Set up the visuals. Pieces can be resused and set up with different params freely.
     * @param options The setup options
     */
    public setup(options: Partial<SlotSpineOptions> = {}) {
        const opts = { ...defaultSlotSpineOptions, ...options };
        this.killTweens();
        this.paused = false;
        this.visible = true;
        this.alpha = 1;
        this.type = opts.type;
        this.name = opts.name;
        this.blurName = opts.blurName;
        this.atlasName = opts.atlasName;
        this.size = opts.size;
        this.spine.alpha = 1;
        this.scale.set(1);
 
        // Replace new spine data without removing the actual spine added above
        this.spine =
        this.spine.width = opts.size;
        this.spine.height = opts.size;
        this.spine.pivot.set(0.5)
 
        this.highlight.visible = opts.highlight;
        this.highlight.width = opts.size;
        this.highlight.height = opts.size;
        this.highlight.alpha = 0.3;
        this.area.width = opts.size;
        this.area.height = opts.size;
        this.area.interactive = opts.interactive;
        this.area.cursor = 'pointer';
       
        this.unlock();
    }


 

SlotSpine.ts

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