自我回答,问题1:八个按钮(btn0-btn8),,下面有加分8个bitmap(bitmap0-8),,点击按钮对应有bitmap的值+=1
1. 首先初始化 public chouNumArray:Array<number> = [0,0,0,0,0,0,0,0]; //用户下注的分数
2. 首先把这8个按钮都放在这个组里:breedGroup,,,
2. 给这个组添加事件监听
3. 给这8个按钮添加name (btnName0----btnName7)属性
4. 截取点击按钮name的最后一个字符串 idx = x.subStr(x.length-1,1);
5. 累加 this.chouNumArray[i] += 1;
6. 赋值
//八个水果加分按钮 this.breedGroup.addEventListener(egret.TouchEvent.TOUCH_TAP, this.kindBtnListItemViewBtnOp, this); /**下注按钮点击事件 */ public kindBtnListItemViewBtnOp(event:egret.Event): void { let tag = event.target; if(tag){ if(tag instanceof (SGJKindBtnListItemView)){ let tagName = tag.name; let idx = tagName.substr(tagName.length-1,1); this.chouNumArray[idx]+=1; this['SGJAddScoreItemView' + idx]['addScoreTxt'].text = this.chouNumArray[idx]; } } }
}