PlantPanel.ts 1014 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /** 可生产产品列表 */
  2. import TableView from "../../../game/component/TableView";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class PlantPanel extends cc.Component {
  6. @property({ type: TableView, displayName: '滚动视图' })
  7. private tableView: TableView = null;
  8. private list_data = null;
  9. start() {
  10. gData.plantData.init_itemIndex = -1;
  11. gData.plantData.init_lock = -1;
  12. this.initScollView();
  13. }
  14. getItemDataByID(id) {
  15. let len = this.list_data.length;
  16. for (var i = 0; i < len; i++) {
  17. if (this.list_data[i].picture == id) {
  18. return i;
  19. }
  20. }
  21. return 0;
  22. }
  23. /**
  24. * 初始化滚动视图
  25. */
  26. private initScollView() {
  27. this.list_data = gData.plantData.productArr;
  28. this.tableView.node.emit('srollview-init', this.list_data)
  29. }
  30. onDestroy() {
  31. // this.tableView.clearItem();
  32. }
  33. }