mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 02:06:53 +08:00
Improved OnAnimationEvent.
This commit is contained in:
parent
34bd5a1479
commit
ff8024ed83
@ -9,9 +9,6 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds =
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
OnAnimationEvent (this: SpineC3Instance, event: string, track: number, animation: string) {
|
OnAnimationEvent (this: SpineC3Instance, event: string, track: number, animation: string) {
|
||||||
console.log(this.triggeredEventName === event
|
|
||||||
&& this.triggeredEventTrack === track
|
|
||||||
&& this.triggeredEventAnimation === animation);
|
|
||||||
return this.triggeredEventName === event
|
return this.triggeredEventName === event
|
||||||
&& this.triggeredEventTrack === track
|
&& this.triggeredEventTrack === track
|
||||||
&& this.triggeredEventAnimation === animation;
|
&& this.triggeredEventAnimation === animation;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { AnimationState, AssetLoader, Event, Skeleton, SkeletonRendererCore, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
|
import type { AnimationState, AnimationStateListener, AssetLoader, Event, Skeleton, SkeletonRendererCore, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
|
||||||
|
|
||||||
const C3 = globalThis.C3;
|
const C3 = globalThis.C3;
|
||||||
const spine = globalThis.spine;
|
const spine = globalThis.spine;
|
||||||
@ -119,56 +119,37 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
|||||||
this._trigger(C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds.OnAnimationEvent);
|
this._trigger(C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds.OnAnimationEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private makeTrackListener = (track: number, animation: string): AnimationStateListener => ({
|
||||||
|
start: () => {
|
||||||
|
this.triggetAnimationEvent("start", track, animation);
|
||||||
|
},
|
||||||
|
dispose: () => {
|
||||||
|
this.triggetAnimationEvent("dispose", track, animation);
|
||||||
|
},
|
||||||
|
event: (_, event) => {
|
||||||
|
this.triggetAnimationEvent("event", track, animation, event);
|
||||||
|
},
|
||||||
|
interrupt: () => {
|
||||||
|
this.triggetAnimationEvent("interrupt", track, animation);
|
||||||
|
},
|
||||||
|
end: () => {
|
||||||
|
this.triggetAnimationEvent("end", track, animation);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.triggetAnimationEvent("complete", track, animation);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
public setAnimation (track: number, animation: string, loop = false) {
|
public setAnimation (track: number, animation: string, loop = false) {
|
||||||
const trackEntry = this.state?.setAnimation(track, animation, loop);
|
const trackEntry = this.state?.setAnimation(track, animation, loop);
|
||||||
if (!trackEntry) return;
|
if (!trackEntry) return;
|
||||||
|
trackEntry.listener = this.makeTrackListener(track, animation);
|
||||||
trackEntry.listener = {
|
|
||||||
start: () => {
|
|
||||||
this.triggetAnimationEvent("start", track, animation);
|
|
||||||
},
|
|
||||||
dispose: () => {
|
|
||||||
this.triggetAnimationEvent("dispose", track, animation);
|
|
||||||
},
|
|
||||||
event: (_, event) => {
|
|
||||||
this.triggetAnimationEvent("event", track, animation, event);
|
|
||||||
},
|
|
||||||
interrupt: () => {
|
|
||||||
this.triggetAnimationEvent("interrupt", track, animation);
|
|
||||||
},
|
|
||||||
end: () => {
|
|
||||||
this.triggetAnimationEvent("end", track, animation);
|
|
||||||
},
|
|
||||||
complete: () => {
|
|
||||||
this.triggetAnimationEvent("complete", track, animation);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public addAnimation (track: number, animation: string, loop = false, delay = 0) {
|
public addAnimation (track: number, animation: string, loop = false, delay = 0) {
|
||||||
const trackEntry = this.state?.addAnimation(track, animation, loop, delay);
|
const trackEntry = this.state?.addAnimation(track, animation, loop, delay);
|
||||||
if (!trackEntry) return;
|
if (!trackEntry) return;
|
||||||
|
trackEntry.listener = this.makeTrackListener(track, animation);
|
||||||
trackEntry.listener = {
|
|
||||||
start: () => {
|
|
||||||
this.triggetAnimationEvent("start", track, animation);
|
|
||||||
},
|
|
||||||
dispose: () => {
|
|
||||||
this.triggetAnimationEvent("dispose", track, animation);
|
|
||||||
},
|
|
||||||
event: (_, event) => {
|
|
||||||
this.triggetAnimationEvent("event", track, animation, event);
|
|
||||||
},
|
|
||||||
interrupt: () => {
|
|
||||||
this.triggetAnimationEvent("interrupt", track, animation);
|
|
||||||
},
|
|
||||||
end: () => {
|
|
||||||
this.triggetAnimationEvent("end", track, animation);
|
|
||||||
},
|
|
||||||
complete: () => {
|
|
||||||
this.triggetAnimationEvent("complete", track, animation);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setSkin (skins: string[]) {
|
public setSkin (skins: string[]) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user