TowerUI.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { _decorator, Component, Node, Sprite, UITransform, Vec2, Vec3, view } from 'cc';
  2. import { ModulerBase } from './ModulerBase';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('TowerUI')
  5. export class TowerUI extends ModulerBase {
  6. private _sell: UITransform = null;
  7. private _upGrade: UITransform = null;
  8. init(): void {
  9. this._sell = this.node.getChildByName("Sell").getComponent(UITransform);
  10. this._upGrade = this.node.getChildByName("UpGrade").getComponent(UITransform);
  11. }
  12. start() {
  13. }
  14. update(deltaTime: number) {
  15. }
  16. touchIcon(pos: Vec2):boolean{
  17. if(this._sell.getBoundingBoxToWorld().contains(pos)){
  18. }
  19. else if(this._upGrade.getBoundingBoxToWorld().contains(pos)){
  20. }
  21. this.hide();
  22. return false;
  23. }
  24. //当前卡片是否显示
  25. isShow(){
  26. return this.node.active;
  27. }
  28. show(pos: Vec3){
  29. //view.getVisibleSize().width;
  30. //view.getVisibleSize().height;
  31. // if(this.node.active){
  32. // this.hide();
  33. // return true;
  34. // }
  35. this.node.setPosition(pos);
  36. this.node.active = true;
  37. }
  38. hide(){
  39. this.node.active = false;
  40. }
  41. }