HeroList.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { _decorator, Label, Node } from 'cc';
  2. import { BaseView } from '../../../framework/layer/BaseView';
  3. import List from '../../../framework/list/List';
  4. import { StringUtil } from '../../../framework/util/StringUtil';
  5. import { HeroListItem, heroListItemData } from './HeroListItem';
  6. import { RoleManager } from '../../manager/RoleManager';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('HeroList')
  9. export class HeroList extends BaseView {
  10. @property({ type: Label, tooltip: "标题" })
  11. titleTx: Label = null;
  12. @property({ type: List, tooltip: "滑动容器" })
  13. sv: List = null;
  14. private _herosData: Array<heroListItemData> = [];
  15. protected onLoad() {
  16. super.onLoad();
  17. this.titleTx.string = StringUtil.getLanguageData('英雄列表');
  18. let data = RoleManager.getRolesRaceGroup();
  19. for (let index = 0; index < 4; index++) {
  20. let t: heroListItemData = { race: index, heros: data[index + 1], equips: {} }
  21. this._herosData.push(t);
  22. }
  23. this.sv.numItems = this._herosData.length;
  24. }
  25. protected onDestroy() {
  26. }
  27. //UI开打时会调用,如果有初始化代码应该放到此函数
  28. onOpen() {
  29. }
  30. //UI关闭时会调用,该函数在onDestroy前调用
  31. onClose() {
  32. }
  33. //框架管理UI层级时会调用,可根据UI情况修改
  34. onShow() {
  35. super.onShow();
  36. }
  37. //框架管理UI层级时会调用,可根据UI情况修改
  38. onHide() {
  39. super.onHide();
  40. }
  41. //UI事件处理
  42. private onTouchButton(event: Event) {
  43. //Framework.audio.playEffect(AudioID.Click);
  44. let target: any = event.target;
  45. }
  46. onEventList(item, idx) {
  47. item.getComponent(HeroListItem).refreshItem(this._herosData[idx]);
  48. }
  49. }