diff --git a/assets/script/game/map/MissionHomeComp.ts b/assets/script/game/map/MissionHomeComp.ts index 3f13a6aa..6ba09bfb 100644 --- a/assets/script/game/map/MissionHomeComp.ts +++ b/assets/script/game/map/MissionHomeComp.ts @@ -80,10 +80,8 @@ export class MissionHomeComp extends CCComp { this.node.active=false; // 隐藏 mapLayer 下的 main 节点 - let mainNode = smc.map.MapView.scene.mapLayer?.node.getChildByName("main"); - if (mainNode) { - mainNode.active = false; - } + smc.map.MapView.scene.mapLayer?.stopAnimations(); + } /** 打开排行榜弹窗 */ @@ -106,12 +104,7 @@ export class MissionHomeComp extends CCComp { home_active(){ this.uodate_data() this.node.active=true - - // 重新显示 mapLayer 下的 main 节点 - let mainNode = smc.map.MapView.scene.mapLayer?.node.getChildByName("main"); - if (mainNode) { - mainNode.active = true; - } + smc.map.MapView.scene.mapLayer?.playAnimations(); } /** 更新主页显示数据(预留) */ diff --git a/assets/script/game/map/view/map/layer/MapLayer.ts b/assets/script/game/map/view/map/layer/MapLayer.ts index 51f21662..ab06b0d2 100644 --- a/assets/script/game/map/view/map/layer/MapLayer.ts +++ b/assets/script/game/map/view/map/layer/MapLayer.ts @@ -18,7 +18,7 @@ * * @author 落日故人 QQ 583051842 */ -import { Component, Layers, Node, Sprite, SpriteFrame, Texture2D, UITransform, Vec3, _decorator } from 'cc'; +import { Animation, Component, Layers, Node, Sprite, SpriteFrame, Texture2D, UITransform, Vec3, _decorator } from 'cc'; import { oops } from '../../../../../../../extensions/oops-plugin-framework/assets/core/Oops'; import { LayerUtil } from '../../../../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil'; import { smc } from '../../../../common/SingletonModuleComp'; @@ -80,6 +80,25 @@ export default class MapLayer extends Component { if (this.bgImg) { return this.bgImg.getComponent(UITransform)!.height; } + } + private get animations(): Animation[] { + return [this.bg_anm, this.bg_anm1, this.bg_anm2, this.bg_anm3, this.bg_anm4].filter((a): a is Animation => a !== null); + } + + public playAnimations(name?: string): void { + this.animations.forEach(a => name ? a.play(name) : a.play()); + } + + public stopAnimations(): void { + this.animations.forEach(a => a.stop()); + } + + public pauseAnimations(): void { + this.animations.forEach(a => a.pause()); + } + + public resumeAnimations(): void { + this.animations.forEach(a => a.resume()); } } \ No newline at end of file