Skip to content

Commit c88785a

Browse files
committed
check trackEntry is loop
1 parent b2a8b12 commit c88785a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

cocos/spine/skeleton.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ export class Skeleton extends UIRenderer {
18861886
const animEnd = math.equals(trackEntry.animationEnd, -1.0) ? trackEntry.animation.duration : trackEntry.animationEnd;
18871887
const duration = animEnd - trackEntry.animationStart;
18881888
if (duration > 0) {
1889-
const loopCount = Math.floor(trackEntry.trackTime / duration);
1889+
const loopCount = trackEntry.loop ? Math.floor(trackEntry.trackTime / duration) : 1;
18901890
listener(trackEntry, loopCount);
18911891
// this._instance.setListener(listenerID, spine.EventType.event);
18921892
// this._listener!.event = listener;

platforms/native/engine/jsb-spine-skeleton.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const cacheManager = require('./jsb-cache-manager');
158158
const animEnd = math.equals(trackEntry.animationEnd, -1.0) ? trackEntry.animation.duration : trackEntry.animationEnd;
159159
const duration = animEnd - trackEntry.animationStart;
160160
if (duration > 0) {
161-
const loopCount = Math.floor(trackEntry.trackTime / duration);
161+
const loopCount = trackEntry.loop ? Math.floor(trackEntry.trackTime / duration) : 1;
162162
this._compeleteListener && this._compeleteListener(trackEntry, loopCount);
163163
} else {
164164
cc.errorID(16420);
@@ -173,7 +173,7 @@ const cacheManager = require('./jsb-cache-manager');
173173
const animEnd = math.equals(trackEntryNative.animationEnd, -1.0) ? trackEntryNative.animation.duration : trackEntryNative.animationEnd;
174174
const duration = animEnd - trackEntryNative.animationStart;
175175
if (duration > 0) {
176-
const loopCount = Math.floor(trackEntryNative.trackTime / duration);
176+
const loopCount = trackEntryNative.loop ? Math.floor(trackEntryNative.trackTime / duration) : 1;
177177
this._trackCompeleteListener && this._trackCompeleteListener(trackEntryNative, loopCount);
178178
} else {
179179
cc.errorID(16420);

0 commit comments

Comments
 (0)