12a0e34e3bb22b035d62aa5221ec3ae2dd5ff48c.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. var 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. var 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 (result_as === void 0) {
  77. result_as = [];
  78. }
  79. if (!node_) {
  80. return result_as;
  81. }
  82. result_as.push(node_);
  83. node_.children.forEach(v1 => {
  84. result_as.push(v1);
  85. this.recu_node_list(v1);
  86. });
  87. return result_as;
  88. }
  89. /**恢复游戏 */
  90. static resume() {
  91. // 恢复定时器
  92. director.getScheduler().resumeTargets(this.pause_data.scheduler_as); // 恢复动画
  93. this.pause_data.anim_as.forEach(v1 => {
  94. if (v1.isPlaying && v1.isPaused) {
  95. v1.play();
  96. }
  97. }); // 恢复龙骨动画
  98. //this.pause_data.dragon_bones_as.forEach(v1 => {
  99. //v1.timeScale = 1;
  100. //});
  101. this.pause_data.spine_as.forEach(v1 => {
  102. v1.timeScale = 1;
  103. }); // 恢复缓动
  104. TweenSystem.instance.ActionManager.resumeTargets(this.pause_data.tween_target_as); // 恢复物理系统
  105. {
  106. if (this.pause_data.physics_2d_b) {
  107. PhysicsSystem2D.instance.enable = this.pause_data.physics_2d_b;
  108. }
  109. if (this.pause_data.physics_3d_b) {
  110. PhysicsSystem.instance.enable = this.pause_data.physics_3d_b;
  111. }
  112. }
  113. this.pause_data.state_b = false;
  114. }
  115. /**暂停节点
  116. * -物理系统需手动启用/禁用
  117. */
  118. static pause_node(args1_) {
  119. var node_as;
  120. if (Array.isArray(args1_)) {
  121. node_as = args1_;
  122. } else {
  123. node_as = [args1_];
  124. }
  125. node_as.forEach(v1 => {
  126. var _v1$getComponent;
  127. // 暂停定时器
  128. director.getScheduler().pauseTarget(v1); // 暂停动画
  129. (_v1$getComponent = v1.getComponent(Animation)) == null || _v1$getComponent.pause(); //暂停spine动画
  130. if (v1.getComponent(sp.Skeleton)) {
  131. v1.getComponent(sp.Skeleton).timeScale = 0;
  132. } // 暂停龙骨
  133. //if (v1.getComponent(dragonBones.ArmatureDisplay)) {
  134. //v1.getComponent(dragonBones.ArmatureDisplay).timeScale = 0;
  135. //}
  136. // 暂停缓动
  137. TweenSystem.instance.ActionManager.pauseTarget(v1);
  138. });
  139. }
  140. /**恢复节点 */
  141. static resume_node(args1_) {
  142. var node_as;
  143. if (Array.isArray(args1_)) {
  144. node_as = args1_;
  145. } else {
  146. node_as = [args1_];
  147. }
  148. node_as.forEach(v1 => {
  149. var _v1$getComponent2;
  150. // 恢复定时器
  151. director.getScheduler().resumeTarget(v1); // 恢复动画
  152. (_v1$getComponent2 = v1.getComponent(Animation)) == null || _v1$getComponent2.resume(); //恢复spine动画
  153. if (v1.getComponent(sp.Skeleton)) {
  154. v1.getComponent(sp.Skeleton).timeScale = 1;
  155. } //恢复龙骨
  156. //if (v1.getComponent(dragonBones.ArmatureDisplay)) {
  157. //v1.getComponent(dragonBones.ArmatureDisplay).timeScale = 1;
  158. //}
  159. // 恢复缓动
  160. TweenSystem.instance.ActionManager.resumeTarget(v1);
  161. });
  162. } //
  163. });
  164. //没有用到龙骨 dragon_bones_as:dragonBones.ArmatureDisplay[]
  165. DirectorUtil.pause_data = {
  166. /**暂停状态 */
  167. state_b: false,
  168. /**2d物理系统状态 */
  169. physics_2d_b: false,
  170. /**3d物理系统状态 */
  171. physics_3d_b: false,
  172. /**定时器对象列表 */
  173. scheduler_as: [],
  174. /**动画列表 */
  175. anim_as: [],
  176. /**缓动对象列表 */
  177. tween_target_as: [],
  178. /**龙骨组件列表 */
  179. //dragon_bones_as:[],
  180. spine_as: []
  181. };
  182. _cclegacy._RF.pop();
  183. _crd = false;
  184. }
  185. };
  186. });
  187. //# sourceMappingURL=12a0e34e3bb22b035d62aa5221ec3ae2dd5ff48c.js.map