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

fix spine cache mode event type bug #209

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 27 additions & 3 deletions engine/jsb-spine-skeleton.js
Expand Up @@ -601,7 +601,15 @@
skeleton.setStartListener = function (listener) {
this._startListener = listener;
if (this._nativeSkeleton) {
this._nativeSkeleton.setStartListener(listener);
if (this.isAnimationCached()) {
this._nativeSkeleton.setStartListener(function (animationName) {
let self = this._comp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self 需要放在外面定义么,这几个 this 都是指向调用者哦

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个this是指向 _nativeSkeleton,_comp在初始化 _nativeSkeleton的时候,把Skeleton组件赋值给了_nativeSkeleton

self._startEntry.animation.name = animationName;
self._startListener && self._startListener(self._startEntry);
});
} else {
this._nativeSkeleton.setStartListener(listener);
}
}
};

Expand All @@ -615,7 +623,15 @@
skeleton.setEndListener = function (listener) {
this._endListener = listener;
if (this._nativeSkeleton) {
this._nativeSkeleton.setEndListener(listener);
if (this.isAnimationCached()) {
this._nativeSkeleton.setEndListener(function (animationName) {
let self = this._comp;
self._endEntry.animation.name = animationName;
self._endListener && self._endListener(self._endEntry);
});
} else {
this._nativeSkeleton.setEndListener(listener);
}
}
};

Expand All @@ -629,7 +645,15 @@
skeleton.setCompleteListener = function (listener) {
this._completeListener = listener;
if (this._nativeSkeleton) {
this._nativeSkeleton.setCompleteListener(listener);
if (this.isAnimationCached()) {
this._nativeSkeleton.setCompleteListener(function (animationName) {
let self = this._comp;
self._endEntry.animation.name = animationName;
self._completeListener && self._completeListener(self._endEntry);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

complete事件使用的是endEntry么

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是,complete和end是同一个事件,在cache模式下。

});
} else {
this._nativeSkeleton.setCompleteListener(listener);
}
}
};

Expand Down