MouseIconDetail.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { MouseConst } from "./MouseConst";
  2. import MouseIconDetailItem from "./MouseIconDetailItem";
  3. import MouseIconView from "./MouseIconView";
  4. const { ccclass, property } = cc._decorator;
  5. @ccclass
  6. export default class MouseIconDetail extends cc.Component {
  7. @property(MouseIconDetailItem)
  8. left: MouseIconDetailItem = null;
  9. @property(MouseIconDetailItem)
  10. right: MouseIconDetailItem = null;
  11. @property(cc.Node)
  12. maskBg: cc.Node = null;
  13. show(mouseIconView: MouseIconView, iconId: number, col: number, row: number) {
  14. this.node.active = true;
  15. this.maskBg.active = true;
  16. this.left.node.active = false;
  17. this.right.node.active = false;
  18. if (row >= MouseConst.GAME_ROW)
  19. return;
  20. if (col < 2) { // 左边
  21. this.left.node.y = MouseConst.IconSize.height * (row - 1);
  22. this.left.node.x = col == 0 ? -133 : 110;
  23. this.left.show(iconId, mouseIconView.getIconSpineById(iconId - 1));
  24. } else { // 右边
  25. this.right.node.y = MouseConst.IconSize.height * (row - 1);
  26. this.right.show(iconId, mouseIconView.getIconSpineById(iconId - 1));
  27. }
  28. }
  29. resetView() {
  30. this.maskBg.active = false;
  31. this.node.active = false;
  32. }
  33. }