import { _decorator, Component, Node, Sprite, UITransform, Vec2, Vec3, view } from 'cc'; import { ModulerBase } from './ModulerBase'; const { ccclass, property } = _decorator; @ccclass('CardMgr') export class CardMgr extends ModulerBase { private _cards: Sprite[] = []; init(): void { this._cards = this.getComponentsInChildren(Sprite); } start() { } update(deltaTime: number) { } touchCard(pos: Vec2):boolean{ for(const sprite of this._cards){ const box = sprite.getComponent(UITransform).getBoundingBoxToWorld(); if(box.contains(pos)){ this.hide(); return true; } } return false; } show(pos: Vec3): boolean{ //view.getVisibleSize().width; //view.getVisibleSize().height; if(this.node.active){ this.hide(); return true; } this.node.setPosition(pos); this.node.active = true; return false; } hide(){ this.node.active = false; } }