1
0

SkillScrollView.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const DWTool = require("../utils/DWTool");
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. item: cc.Node,
  6. content: cc.Node,
  7. },
  8. // LIFE-CYCLE CALLBACKS:
  9. onLoad () {
  10. },
  11. start () {
  12. },
  13. //// 重新判断一下是否可用
  14. updateUI () {
  15. for (let i = 0; i < this._items.length; ++ i) {
  16. let item = this._items[i];
  17. item.setupGrayBg(item.judgeIsCanUse());
  18. item.setupMaxLevel();
  19. }
  20. },
  21. update (dt) {},
  22. init(skillData) {
  23. let arr = skillData.skills1.concat(skillData.skills2);
  24. this.item.getComponent('SkillItem').initBuilding(skillData.awardCount);
  25. this._items = [];
  26. // this.skillData = skillData;
  27. // this.item.getComponent('SkillItem').init(this, skillData[0]);
  28. /// 循环遍历
  29. for(let i = 0; i < arr.length; i++) {
  30. let contentItem = cc.instantiate(this.item);
  31. this.content.addChild(contentItem);
  32. contentItem.active = true;
  33. let itemScript = contentItem.getComponent('SkillItem')
  34. itemScript.init(arr[i]);
  35. this._items.push(itemScript);
  36. }
  37. }
  38. });