Nanfeng

Notes on software development, code, and curious ideas

Cocos Creator Spine Pause, Resume and Restart with sp.Skeleton

Pause and Resume with sp.Skeleton.paused

pauseAllActions() on the node does not pause a Spine skeleton. Use the paused property:

1
2
3
4
const skeleton = this.spineNode.getComponent(sp.Skeleton);

function pause() { skeleton.paused = true; }
function resume() { skeleton.paused = false; }

Restart with clearTrack and setAnimation

This resumes from the paused position. To stop and replay from the beginning:

1
2
function stop() { skeleton.clearTrack(0); }
function restart() { skeleton.setAnimation(0, 'animation', false); }
+