SkeletonExt.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. cc.game.once(cc.game.EVENT_ENGINE_INITED, function () {
  2. cc.js.mixin(sp.Skeleton.prototype, {
  3. update (dt) {
  4. // if (CC_EDITOR) return;
  5. if (CC_EDITOR) {
  6. cc.engine._animatingInEditMode = 1;
  7. cc.engine.animatingInEditMode = 1;
  8. }
  9. if (this.paused) return;
  10. dt *= this.timeScale * sp.timeScale;
  11. if (this.isAnimationCached()) {
  12. // Cache mode and has animation queue.
  13. if (this._isAniComplete) {
  14. if (this._animationQueue.length === 0 && !this._headAniInfo) {
  15. let frameCache = this._frameCache;
  16. if (frameCache && frameCache.isInvalid()) {
  17. frameCache.updateToFrame();
  18. let frames = frameCache.frames;
  19. this._curFrame = frames[frames.length - 1];
  20. }
  21. return;
  22. }
  23. if (!this._headAniInfo) {
  24. this._headAniInfo = this._animationQueue.shift();
  25. }
  26. this._accTime += dt;
  27. if (this._accTime > this._headAniInfo.delay) {
  28. let aniInfo = this._headAniInfo;
  29. this._headAniInfo = null;
  30. this.setAnimation (0, aniInfo.animationName, aniInfo.loop);
  31. }
  32. return;
  33. }
  34. this._updateCache(dt);
  35. } else {
  36. this._updateRealtime(dt);
  37. }
  38. }
  39. })
  40. })