SelectCellItemBtn.ts 974 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import GamePlay from "../../GamePlay";
  2. import GameConst from "../../data/GameConst";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class SelectCellItemBtn extends cc.Component {
  6. /**cellItem的ani效果 */
  7. @property(cc.Sprite)
  8. spr_icon: cc.Sprite = null;
  9. /**类型 */
  10. public type: number = 0;
  11. start() {
  12. this.node.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
  13. }
  14. /**初始化 */
  15. init(cellItemType: number) {
  16. this.type = cellItemType;
  17. this.spr_icon.node.width = 70;
  18. this.spr_icon.node.height = 70;
  19. mk.loader.load(`game/texture/cellItemIcon/${GameConst.iconIndex}/${this.type}`, cc.SpriteFrame).then((spriteFrame) => {
  20. this.spr_icon.spriteFrame = spriteFrame;
  21. })
  22. }
  23. onClick() {
  24. GamePlay.Inst.node_changeCellItemUI.active = false;
  25. GamePlay.Inst.changeCellItemType(this.type);
  26. }
  27. }