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

@pixi-spine/all-4.0 - AnimationStateListener functions should be optional #412

Closed
jmlee2k opened this issue Sep 22, 2021 · 5 comments · Fixed by #413
Closed

@pixi-spine/all-4.0 - AnimationStateListener functions should be optional #412

jmlee2k opened this issue Sep 22, 2021 · 5 comments · Fixed by #413

Comments

@jmlee2k
Copy link
Contributor

jmlee2k commented Sep 22, 2021

  • only a problem for state.addListener, adding a listener to an individual track works as expected.
  • limited to @pixi-spine/all-4.0 - @pixi-spine/all-3.8, and the main pixi-spine package work as expected.

Due to this, code like this will not work, since all the functions have to be present:

const listener = {
    event:(entry,ev)=>{
        ...
    }
}
spine.state.addListener(listener);

I've tested that it works by casting the listener to AnimationStateListener, so we know the runtime isn't calling functions that aren't defined.

In @pixi-spine/all-3.8 (correct)

export declare interface AnimationStateListener extends IAnimationStateListener {
    /** Invoked when this entry has been set as the current entry. */
    start?(entry: TrackEntry): void;
    /** Invoked when another entry has replaced this entry as the current entry. This entry may continue being applied for
     * mixing. */
    interrupt?(entry: TrackEntry): void;
    /** Invoked when this entry is no longer the current entry and will never be applied again. */
    end?(entry: TrackEntry): void;
    /** Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry.
     * References to the entry should not be kept after dispose is called, as it may be destroyed or reused. */
    dispose?(entry: TrackEntry): void;
    /** Invoked every time this entry's animation completes a loop. */
    complete?(entry: TrackEntry): void;
    /** Invoked when this entry's animation triggers an event. */
    event?(entry: TrackEntry, event: Event_2): void;
}

in @pixi-spine/all-4.0 (all functions should be optional as in 3.8)

export declare interface AnimationStateListener extends IAnimationStateListener {
    /** Invoked when this entry has been set as the current entry. */
    start(entry: TrackEntry): void;
    /** Invoked when another entry has replaced this entry as the current entry. This entry may continue being applied for
     * mixing. */
    interrupt(entry: TrackEntry): void;
    /** Invoked when this entry is no longer the current entry and will never be applied again. */
    end(entry: TrackEntry): void;
    /** Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry.
     * References to the entry should not be kept after dispose is called, as it may be destroyed or reused. */
    dispose(entry: TrackEntry): void;
    /** Invoked every time this entry's animation completes a loop. */
    complete(entry: TrackEntry): void;
    /** Invoked when this entry's animation triggers an event. */
    event(entry: TrackEntry, event: Event_2): void;
}
@ivanpopelyshev
Copy link
Collaborator

Its the same as in https://github.com/EsotericSoftware/spine-runtimes/blob/db92cb3667c88bb819bd24c09f839529e0df4aa5/spine-ts/spine-core/src/AnimationState.ts#L1096-L1116

If you think it can be optional, you can make PR's both here and in main repo

@jmlee2k
Copy link
Contributor Author

jmlee2k commented Sep 23, 2021

Hi Ivan, thanks for the response. I noticed they weren't optional in https://github.com/EsotericSoftware/spine-runtimes, but they also weren't optional in their 3.8 branch, so I thought you may be doing something custom here.

I was going to make a PR, but I'm not exactly sure where the code for the @pixi-spine/runtime-4.0 package is.

@ivanpopelyshev
Copy link
Collaborator

@jmlee2k
Copy link
Contributor Author

jmlee2k commented Sep 23, 2021

Great, thanks, I was looking the bundles dir. :|

I'll make a PR soon.

@smlmyck
Copy link
Contributor

smlmyck commented Nov 30, 2021

Is there any chance this fix could be released through NPM? We've just swapped to Spine 4.0 and we're now seeing this issue using the current latest (3.0.13) of @pixi-spine/all-4.0, would save us some anys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants