import { GuideEvent } from "../../../data/const/EventConst"; import { ViewZorder } from "../../../data/const/ViewZOrder"; import UEBase from "../../../frameWork/compment/UEBase"; import EventMng from "../../../manager/EventMng"; import { uiCommon } from "../../../utils/UICommon"; const { ccclass, menu, property } = cc._decorator; @ccclass @menu("UI/persistNode/UIHandMaskView") export default class UIHandMaskView extends UEBase { static readonly BundleKey: string = "guide"; static readonly PrefabUrl: string = "UIHandMaskView"; static readonly CLS: string = "UIHandMaskView"; @property(cc.Node) mask: cc.Node = null @property(cc.SpriteFrame) taskzhezhao: cc.SpriteFrame = null @property(cc.SpriteFrame) imgMask: cc.SpriteFrame = null private targetNodeScale: number = 1 //目标节点真实sacle protected onEnable() { // cc.game.addPersistRootNode(this.node); this.node.zIndex = ViewZorder.UI_MASK; EventMng.on(GuideEvent.HANDMASK_SHOW, this.ShowHandMask, this) } protected onDisable() { } ShowHandMask(targetNode: cc.Node, maskName: string) { if (!targetNode) { this.mask.active = false; return; } this.mask.active = true; let targetWolrdPos = uiCommon.getWorldPosCenter(targetNode) this.targetNodeScale = targetNode.scale let maskScale = 1 this.getRealScale(targetNode) // this.mask.getComponent(cc.Mask).spriteFrame = this[maskName]; this.scheduleOnce(() => { this.mask.width = targetNode.width * this.targetNodeScale * maskScale this.mask.height = targetNode.height * this.targetNodeScale * maskScale }, 0.02) this.mask.angle = targetNode.angle uiCommon.setWorldPos(this.mask, targetWolrdPos) } //获取目标节点真实sacle getRealScale(root: cc.Node) { if (root.parent != null) { this.targetNodeScale *= root.parent.scale this.getRealScale(root.parent) } } }