Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to disable or destroy entity in the complete callback #66

Open
ChrisRegan opened this issue Aug 11, 2022 · 0 comments
Open

Unable to disable or destroy entity in the complete callback #66

ChrisRegan opened this issue Aug 11, 2022 · 0 comments
Labels

Comments

@ChrisRegan
Copy link

When trying to disable or destroy an entity at the end of an animation. I either throws an error saying the skeleton cannot be null or keeps rendering the last frame of the animation.

SpineAnim.prototype.LoadSpine = function(entityName)
{
        this.entity.spine.spine.skeleton.setSkinByName("default");
        this.entity.spine.spine.skeleton.setSlotsToSetupPose();
        
        this.entity.spine.states[1] = new spine.AnimationState(this.entity.spine.spine.stateData);

        this.delegateObj = {
            complete: this.onComplete.bind(this),
            interrupt: this.onComplete.bind(this)
        };

        this.entity.spine.state.addListener(this.delegateObj);
            this.entity.spine.state.defaultMix = 0.2;
           this.entity.spine.state.addAnimation(0, "Idle", false);
};

SpineAnim.prototype.onComplete = function(track){

//this.entity.enabled = false <- doesnt work.  continues to render last frame.
//this.entity.destroy();  <- throws an error saying skeleton cannot be null.

  setTimeout(function(){this.entity.enabled = false;}.bind(this), 10); // <- works because it is outside of the on complete function.
        
};

@ChrisRegan ChrisRegan changed the title Unable to disable or destroy entity on complete Unable to disable or destroy entity in the complete callback Aug 11, 2022
@yaustar yaustar added the bug label Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants