| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import GamePlay from "../GamePlay";
- import { PROPTYPE } from "../data/Enum";
- import SelectCellItemBtn from "./uiItem/SelectCellItemBtn";
- import GameConst from "../data/GameConst";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class ChangeCellItemUI extends cc.Component {
- @property(cc.Layout)
- layout_selectCellItemBtn: cc.Layout = null;
- @property(cc.Node)
- node_closeBtn: cc.Node = null;
- @property(cc.Prefab)
- prefab_selectCellItemBtn: cc.Prefab = null;
- public curIconIndex: number = null;
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {}
- onEnable() {
- if (this.curIconIndex != GameConst.iconIndex) {
- this.initSelectCellItemBtn();
- this.curIconIndex = GameConst.iconIndex;
- }
- }
- onDisable() {
- GamePlay.Inst.ifCouldClick = true;
- if (GamePlay.Inst.curSelectCellItem) {
- GamePlay.Inst.curSelectCellItem.node.opacity = 255;
- }
- }
- start() {
- this.node_closeBtn.on(cc.Node.EventType.TOUCH_END, this.onClickClose, this);
- }
- // update (dt) {}
- /**初始化选择CellItemBtn */
- initSelectCellItemBtn() {
-
- if (this.layout_selectCellItemBtn.node.childrenCount > 0) {
- for (var i = 1; i <= this.layout_selectCellItemBtn.node.childrenCount; i++) {
- mk.console.log(" node_selectCellItemBtn i", i)
- let node_selectCellItemBtn = this.layout_selectCellItemBtn.node.children[i - 1];
- let selecCellItemBtn = node_selectCellItemBtn.getComponent(SelectCellItemBtn);
- selecCellItemBtn.init(i);
- }
- return;
- }
- for (var i = 1; i <= 6; i++) {
- let node_selectCellItemBtn = cc.instantiate(this.prefab_selectCellItemBtn);
- mk.console.log("初始化选择按钮!!!!!!!!!!!!!!!!!!!!", i);
- let selecCellItemBtn = node_selectCellItemBtn.getComponent(SelectCellItemBtn);
- selecCellItemBtn.init(i);
- this.layout_selectCellItemBtn.node.addChild(node_selectCellItemBtn);
- }
- }
- onClickClose() {
- this.node.active = false;
- }
- }
|