Skip to content

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

@ChrisRegan

Description

@ChrisRegan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions