a1b3c5a95f69b723730bd0dbf203c64c27bca2ef.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, director, TweenSystem, PhysicsSystem, PhysicsSystem2D, AnimationManager, sp, Animation, DirectorUtil, _crd;
  4. _export("default", void 0);
  5. return {
  6. setters: [function (_cc) {
  7. _cclegacy = _cc.cclegacy;
  8. __checkObsolete__ = _cc.__checkObsolete__;
  9. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  10. director = _cc.director;
  11. TweenSystem = _cc.TweenSystem;
  12. PhysicsSystem = _cc.PhysicsSystem;
  13. PhysicsSystem2D = _cc.PhysicsSystem2D;
  14. AnimationManager = _cc.AnimationManager;
  15. sp = _cc.sp;
  16. Animation = _cc.Animation;
  17. }],
  18. execute: function () {
  19. _crd = true;
  20. _cclegacy._RF.push({}, "0dd04xSWM1G07cwb9c87Tja", "DirectorUtil", undefined);
  21. __checkObsolete__(['director']);
  22. __checkObsolete__(['TweenSystem']);
  23. __checkObsolete__(['PhysicsSystem']);
  24. __checkObsolete__(['PhysicsSystem2D']);
  25. __checkObsolete__(['AnimationManager']);
  26. __checkObsolete__(['sp']);
  27. __checkObsolete__(['Animation', 'AnimationState', 'Node']);
  28. _export("default", DirectorUtil = class DirectorUtil {
  29. /**暂停游戏 */
  30. static pause(config_) {
  31. if (this.pause_data.state_b) return; // 暂停定时器
  32. this.pause_data.scheduler_as = director.getScheduler().pauseAllTargets(); // 暂停当前动画
  33. {
  34. let anim_system = director.getSystem(AnimationManager.ID);
  35. this.pause_data.anim_as.splice(0, this.pause_data.anim_as.length, ...anim_system["_anims"].array);
  36. this.pause_data.anim_as.forEach(v1 => {
  37. v1.pause();
  38. });
  39. } // 暂停spine动画
  40. {
  41. this.pause_data.spine_as = director.getScene().getComponentsInChildren(sp.Skeleton);
  42. this.pause_data.spine_as.forEach(v1 => {
  43. v1.timeScale = 0;
  44. });
  45. } // 暂停龙骨动画
  46. // {
  47. //this.pause_data.dragon_bones_as = director.getScene().getComponentsInChildren(dragonBones.ArmatureDisplay);
  48. //this.pause_data.dragon_bones_as.forEach(v1 => {v1.timeScale = 0;});
  49. //}
  50. // 暂停当前缓动
  51. this.pause_data.tween_target_as = TweenSystem.instance.ActionManager.pauseAllRunningActions(); // 暂停物理系统
  52. {
  53. if (PhysicsSystem2D && PhysicsSystem2D.instance.enable) {
  54. this.pause_data.physics_2d_b = PhysicsSystem2D.instance.enable;
  55. PhysicsSystem2D.instance.enable = false;
  56. }
  57. if (PhysicsSystem && PhysicsSystem.instance.enable) {
  58. this.pause_data.physics_3d_b = PhysicsSystem.instance.enable;
  59. PhysicsSystem.instance.enable = false;
  60. }
  61. } // 恢复排除节点
  62. if (config_) {
  63. var _config_$recu_exclude;
  64. let exclude_as = [];
  65. exclude_as.push(...config_.exclude_as);
  66. (_config_$recu_exclude = config_.recu_exclude_as) == null || _config_$recu_exclude.forEach(v1 => {
  67. exclude_as.push(...this.recu_node_list(v1));
  68. });
  69. exclude_as.forEach(v1 => {
  70. this.resume_node(v1);
  71. });
  72. }
  73. this.pause_data.state_b = true;
  74. }
  75. static recu_node_list(node_, result_as = []) {
  76. if (!node_) {
  77. return result_as;
  78. }
  79. result_as.push(node_);
  80. node_.children.forEach(v1 => {
  81. result_as.push(v1);
  82. this.recu_node_list(v1);
  83. });
  84. return result_as;
  85. }
  86. /**恢复游戏 */
  87. static resume() {
  88. // 恢复定时器
  89. director.getScheduler().resumeTargets(this.pause_data.scheduler_as); // 恢复动画
  90. this.pause_data.anim_as.forEach(v1 => {
  91. if (v1.isPlaying && v1.isPaused) {
  92. v1.play();
  93. }
  94. }); // 恢复龙骨动画
  95. //this.pause_data.dragon_bones_as.forEach(v1 => {
  96. //v1.timeScale = 1;
  97. //});
  98. this.pause_data.spine_as.forEach(v1 => {
  99. v1.timeScale = 1;
  100. }); // 恢复缓动
  101. TweenSystem.instance.ActionManager.resumeTargets(this.pause_data.tween_target_as); // 恢复物理系统
  102. {
  103. if (this.pause_data.physics_2d_b) {
  104. PhysicsSystem2D.instance.enable = this.pause_data.physics_2d_b;
  105. }
  106. if (this.pause_data.physics_3d_b) {
  107. PhysicsSystem.instance.enable = this.pause_data.physics_3d_b;
  108. }
  109. }
  110. this.pause_data.state_b = false;
  111. }
  112. /**暂停节点
  113. * -物理系统需手动启用/禁用
  114. */
  115. static pause_node(args1_) {
  116. let node_as;
  117. if (Array.isArray(args1_)) {
  118. node_as = args1_;
  119. } else {
  120. node_as = [args1_];
  121. }
  122. node_as.forEach(v1 => {
  123. var _v1$getComponent;
  124. // 暂停定时器
  125. director.getScheduler().pauseTarget(v1); // 暂停动画
  126. (_v1$getComponent = v1.getComponent(Animation)) == null || _v1$getComponent.pause(); //暂停spine动画
  127. if (v1.getComponent(sp.Skeleton)) {
  128. v1.getComponent(sp.Skeleton).timeScale = 0;
  129. } // 暂停龙骨
  130. //if (v1.getComponent(dragonBones.ArmatureDisplay)) {
  131. //v1.getComponent(dragonBones.ArmatureDisplay).timeScale = 0;
  132. //}
  133. // 暂停缓动
  134. TweenSystem.instance.ActionManager.pauseTarget(v1);
  135. });
  136. }
  137. /**恢复节点 */
  138. static resume_node(args1_) {
  139. let node_as;
  140. if (Array.isArray(args1_)) {
  141. node_as = args1_;
  142. } else {
  143. node_as = [args1_];
  144. }
  145. node_as.forEach(v1 => {
  146. var _v1$getComponent2;
  147. // 恢复定时器
  148. director.getScheduler().resumeTarget(v1); // 恢复动画
  149. (_v1$getComponent2 = v1.getComponent(Animation)) == null || _v1$getComponent2.resume(); //恢复spine动画
  150. if (v1.getComponent(sp.Skeleton)) {
  151. v1.getComponent(sp.Skeleton).timeScale = 1;
  152. } //恢复龙骨
  153. //if (v1.getComponent(dragonBones.ArmatureDisplay)) {
  154. //v1.getComponent(dragonBones.ArmatureDisplay).timeScale = 1;
  155. //}
  156. // 恢复缓动
  157. TweenSystem.instance.ActionManager.resumeTarget(v1);
  158. });
  159. } //
  160. });
  161. //没有用到龙骨 dragon_bones_as:dragonBones.ArmatureDisplay[]
  162. DirectorUtil.pause_data = {
  163. /**暂停状态 */
  164. state_b: false,
  165. /**2d物理系统状态 */
  166. physics_2d_b: false,
  167. /**3d物理系统状态 */
  168. physics_3d_b: false,
  169. /**定时器对象列表 */
  170. scheduler_as: [],
  171. /**动画列表 */
  172. anim_as: [],
  173. /**缓动对象列表 */
  174. tween_target_as: [],
  175. /**龙骨组件列表 */
  176. //dragon_bones_as:[],
  177. spine_as: []
  178. };
  179. _cclegacy._RF.pop();
  180. _crd = false;
  181. }
  182. };
  183. });
  184. //# sourceMappingURL=a1b3c5a95f69b723730bd0dbf203c64c27bca2ef.js.map