HeroList.ts 1.3 KB

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