difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
"use strict";
cc._RF.push(module, 'b5f7bxGxstOdZW8ILFgEQLI', 'star_tower_list');
// Scripts/mod/startower/view/star_tower_list.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      自动意义的scrollview 试练塔的
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var LoaderManager = require("loadermanager");
 
var PathTool = require("pathtool");
 
var CommonScrollViewSingleLayout = require("common_scrollview_single");
 
var StartowerController = require("startower_controller");
 
var RoleController = require("role_controller");
 
var PlayerHead = require("playerhead");
 
var StarTowerList = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {
    this.initConfig();
  },
  initConfig: function initConfig() {
    this.parent = null;
    this.prefabPath = PathTool.getPrefabPath("startower", "star_tower_scroll_view");
    this.pos = cc.v2(0, 0);
    this.dir = ScrollViewDir.vertical;
    this.start_pos = ScrollViewStartPos.bottom;
    this.size = cc.size(100, 100);
    this.ap = cc.v2(0.5, 0);
    this.cellList = []; // 存放所有格子结构体
 
    this.cacheList = []; // 缓存Cell所用到的对象
 
    this.activeCellIdx = []; //记录活跃得格子ID
 
    this.selectCellIndex = 1; //当前选择物品的索引
 
    this.handler = {}; //函数句柄                      
 
    this.start_x = 325; // 第一个单元的起点X
 
    this.space_x = 0; // 横向间隔空间
 
    this.start_y = 185; // 第一个单元的起点Y
 
    this.space_y = 0; // 竖向间隔空间
 
    this.item_width = 300; // 单元的宽度
 
    this.item_height = 120; // 单元的高度
 
    this.col = 1; // 列数,作用于垂直方向的滚动
    //背景相对塔移动的系数
 
    this.bg_param = 3;
  },
 
  /**
   * 创建
   * @param {*} parent 所在父节点
   * @param {*} pos 滑动组件位置
   * @param {*} dir 滑动对齐方式
   * @param {*} start_pos 滑动列表开始位置
   * @param {*} size 滑动框大小
   * @param {*} ap 锚点
   */
  createScroll: function createScroll(parent, pos, size) {
    this.parent = parent;
    this.pos = pos || cc.v2(0, 0);
    this.size = size || cc.size(100, 100); //计算一个屏幕最大数量
 
    this.cacheMaxSize = (Math.ceil(this.size.height / (this.item_height + this.space_y)) + 1) * this.col;
    LoaderManager.getInstance().loadRes(this.prefabPath, function (res_object) {
      var scroll = res_object;
      this.createRootWnd(scroll);
    }.bind(this));
  },
  // 初始化创建对象
  createRootWnd: function createRootWnd(scroll) {
    this.root_wnd = scroll;
    this.scroll_view = scroll.getChildByName("ScrollView");
    this.scroll_view_mask = this.scroll_view.getChildByName("view");
    this.scroll_view_con = this.scroll_view_mask.getChildByName("content");
    this.scroll_view.zIndex = 2;
    this.root_wnd.setContentSize(this.size);
    this.root_wnd.setAnchorPoint(this.ap.x, this.ap.y);
    this.root_wnd.setPosition(this.pos);
    this.scroll_view.setContentSize(this.size);
    this.scroll_view_mask.setContentSize(this.size);
    this.scroll_view_con.setContentSize(this.size);
    this.arrow_btn = this.scroll_view_con.getChildByName("arrow_btn");
    this.arrow_btn.active = true;
    this.arrow_btn.zIndex = 10;
    var role_vo = RoleController.getInstance().getRoleVo();
    this.head = new PlayerHead();
    this.head.show();
    this.head.setScale(0.6);
    this.head.setPosition(47, 0);
    this.head.setParent(this.arrow_btn);
    this.head.setHeadRes(role_vo.face_id); // 滚动组建
 
    this.scroll_view_compend = this.scroll_view.getComponent(cc.ScrollView);
 
    if (this.dir == ScrollViewDir.vertical) {
      this.scroll_view_compend.vertical = true;
    } else {
      this.scroll_view_compend.horizontal = true;
    }
 
    this.container = this.scroll_view_con;
 
    if (this.parent) {
      this.parent.addChild(scroll);
    } // 监听事件
 
 
    this.setInnerContainer();
    this.updateBgList();
    this.registerEvent();
 
    if (this.select_index != null) {
      this.reloadData(this.select_index);
    }
  },
  registerEvent: function registerEvent() {
    this.scroll_view_compend.node.on('scrolling', this.checkRectIntersectsRect, this);
    this.arrow_btn.on(cc.Node.EventType.TOUCH_END, function () {
      Utils.playButtonSound(ButtonSound.Normal);
      this.moveToArrowNewPosition();
    }, this);
  },
  // 注册事件
  //  注册回调方法
  registerScriptHandlerSingle: function registerScriptHandlerSingle(func, handlerId) {
    this.handler[handlerId] = func;
  },
  // 获取cell数量
  numberOfCells: function numberOfCells() {
    if (!this.handler[ScrollViewFuncType.NumberOfCells]) return;
    return this.handler[ScrollViewFuncType.NumberOfCells]();
  },
  //刷新每一个cell 
  updateCellByIndex: function updateCellByIndex(cell, index) {
    if (!this.handler[ScrollViewFuncType.UpdateCellByIndex]) return;
    this.handler[ScrollViewFuncType.UpdateCellByIndex](cell, index);
  },
  // 创建一个新cell
  createNewCell: function createNewCell() {
    if (!this.handler[ScrollViewFuncType.CreateNewCell]) return;
    return this.handler[ScrollViewFuncType.CreateNewCell](this.item_width, this.item_height);
  },
  // 点击cell --在createNewCell 自行实现
  onCellTouched: function onCellTouched(cell, index) {
    if (!this.handler[ScrollViewFuncType.OnCellTouched]) return;
    this.handler[ScrollViewFuncType.OnCellTouched](cell, index);
  },
  // 设置 scrollview 是否可点
  setClickEnabled: function setClickEnabled(status) {
    this.scroll_view.setClickEnabled(status);
  },
  // 设置 是否吞噬点击
  setSwallowTouches: function setSwallowTouches(status) {
    this.scroll_view.setSwallowTouches(status);
  },
  //移动的过程中盘点是否不再可视范围,不再的时候移除掉,放到对象池,并且准备下一次创建
  checkRectIntersectsRect: function checkRectIntersectsRect(event) {
    if (this.dir == ScrollViewDir.vertical) {
      this.checkOverShowByVertical();
    }
  },
  //竖直方向的监测判断
  checkOverShowByVertical: function checkOverShowByVertical() {
    if (this.cellList == null) return;
    var container_y = this.container.y;
 
    if (this.scroll_view_bg) {
      var container = this.scroll_view_bg.getContainer();
 
      if (container) {
        container.y = container_y / this.bg_param;
        this.scroll_view_bg.checkOverShowByVerticalBottom();
      }
    } // 计算 视图的上部分和下部分在this.container 的位置
 
 
    var bot = -container_y;
    var top = this.size.height + bot;
    var col_count = Math.ceil(this.cellList.length / this.col); // 下面因为 this.cellList 是一维数组 所以要换成二维来算
    // 活跃cell开始行数
 
    var activeCellStartRow = col_count;
 
    for (var i = col_count - 1; i >= 0; i--) {
      var index = i * this.col;
      var cell = this.cellList[index];
      activeCellStartRow = i;
 
      if (cell && cell.y <= top) {
        break;
      }
    } // 活跃cell结束行数
 
 
    var activeCellEndRow = 1;
 
    if (bot > 0) {
      for (var j = activeCellStartRow; j >= 0; j--) {
        var index = j * this.col;
        var cell = this.cellList[index];
 
        if (cell && cell.y + this.item_height < bot) {
          activeCellEndRow = j + 1;
          break;
        }
      }
    }
 
    var max_count = this.numberOfCells();
 
    for (var i = 0; i < col_count; i++) {
      if (i <= activeCellStartRow && i >= activeCellEndRow) {
        for (var j = 0; j < this.col; j++) {
          var index = i * this.col + j;
 
          if (!this.activeCellIdx[index]) {
            if (index <= max_count) {
              this.updateCellAtIndex(index);
              this.activeCellIdx[index] = true;
            }
          }
        }
      } else {
        for (var j = 0; j < this.col; j++) {
          var index = i * this.col + j;
 
          if (index <= max_count) {
            this.activeCellIdx[index] = false;
          }
        }
      }
    }
 
    this.updateArrowPos(top, bot);
  },
  //滚动容器移动到指定位置
  updateMove: function updateMove(pos) {
    var target_pos = this.checkPosition(pos.x, pos.y);
    var move_to = cc.moveTo(0.1, target_pos.x, target_pos.y).easing(cc.easeBackOut());
    this.container.runAction(move_to);
  },
  //跳转指定位置
  jumpToMove: function jumpToMove(pos, time, callback) {
    var target_pos = this.checkPosition(pos.x, pos.y);
    time = time || 1;
    var move_to = cc.moveTo.create(time, cc.v2(target_pos.x, target_pos.y));
    this.container.runAction(cc.sequence.create(move_to, cc.callFunc.create(function () {
      if (callback) {
        callback();
      }
    })));
  },
  //监测目标点位置
  checkPosition: function checkPosition(x, y) {
    var _x = this.container.x;
    var _y = this.container.y;
 
    if (this.dir == ScrollViewDir.horizontal) {
      _x = _x + x;
    } else if (this.dir == ScrollViewDir.vertical) {
      _y = _y + y;
    }
 
    if (_x > 0) {
      _x = 0;
    } else if (_x < this.size.width - this.container_size.width) {
      _x = this.size.width - this.container_size.width;
    }
 
    if (_y > 0) {
      _y = 0;
    } else if (_y < this.size.height - this.container_size.height) {
      _y = this.size.height - this.container_size.height;
    }
 
    return cc.v2(_x, _y);
  },
  //设置滚动容器的大小
  setInnerContainer: function setInnerContainer() {
    if (!this.root_wnd) return;
    var number = this.numberOfCells();
    var container_width = this.size.width;
    var num = Math.ceil(number / this.col);
    var container_height = num * this.item_height + 2 * this.start_y + (num - 1) * this.space_y; // 加上塔顶 
 
    container_height = container_height + 453; // 根据塔顶图片高度决定的    
    // 塔底座 在这里 this.start_y 算了
 
    container_height = Math.max(container_height, this.size.height);
    this.container_size = cc.size(container_width, container_height);
 
    if (this.scroll_view_con) {
      this.scroll_view_con.setContentSize(this.container_size);
    }
 
    if (this.start_pos == ScrollViewStartPos.bottom) {
      this.scroll_view_compend.scrollToBottom(0);
    }
  },
  // 刷新当前显示的item数据 (不改变任何位置的)
  resetCurrentItems: function resetCurrentItems() {
    for (var i in this.activeCellIdx) {
      if (this.activeCellIdx[i]) {
        this.updateCellAtIndex(i);
      }
    }
  },
  // 根据index 刷新对应索引..如果在显示视图内
  resetItemByIndex: function resetItemByIndex(index) {
    // body
    if (this.activeCellIdx[index]) {
      this.updateCellAtIndex(index);
    }
  },
  // 获取活跃中的cell对象
  getActiveCellList: function getActiveCellList() {
    var list = [];
 
    for (var i in this.activeCellIdx) {
      if (this.activeCellIdx[i] && this.cellList[i] && this.cellList[i].cell) {
        list.push(this.cellList[i].cell);
      }
    }
 
    return list;
  },
  // 获取index索引对应cell(不管是否活跃)
  getCellByIndex: function getCellByIndex(index) {
    if (this.cellList[index] && this.cellList[index].cell) {
      return this.cellList[i].cell;
    }
  },
  // 获取index索引对应cellXY位置(不管是否活跃)
  getCellXYByIndex: function getCellXYByIndex(index) {// if(this.cellList[index] && this.cellList[index].cell){
    //     return this.cellList[i].x, this.cellList[i].y 
    // }
  },
  // desc:设置数据
  // select_idnex 从第几个开始
  reloadData: function reloadData(select_index) {
    if (this.root_wnd == null) {
      this.select_index = select_index;
      return;
    }
 
    this.cellList = [];
    this.activeCellIdx = [];
 
    for (var i in this.cacheList) {
      // 相当于隐藏
      this.cacheList[i].setPosition(-10000, 0);
    } // 设置容器大小
    // -- this:setInnerContainer()
 
 
    var number = this.numberOfCells();
    if (number == 0) return; // 先初始化中间背景
    // -- this:updateBgList()
 
    for (var i = 0; i < number; i++) {
      var cell = this.getCacheCellByIndex(i);
      var count = this.cellList.length;
      var xy = this.getCellPosition(count);
      var cellData = {
        cell: cell,
        x: xy.x,
        y: xy.y
      };
      this.cellList.push(cellData);
    }
 
    if (select_index == null) {
      var maxRefreshNum = this.cacheMaxSize - this.col;
      var refreshNum = number < maxRefreshNum && number || maxRefreshNum;
 
      for (var j = 0; j < refreshNum; j++) {
        this.updateCellAtIndex(j);
        this.activeCellIdx[j] = true;
      }
    } else {
      this.selectCellByIndex(select_index);
    } // 延迟加个塔底
 
 
    gcore.Timer.set(function () {
      if (this.bottom_bg == null) {
        this.bottom_bg = Utils.createImage(this.container, null, this.start_x + this.item_width * 0.5 - 19, 15, cc.v2(0.5, 0), false, 3, false);
        LoaderManager.getInstance().loadRes(PathTool.getBigBg("bigbg_28"), function (resObject) {
          this.bottom_bg.spriteFrame = resObject;
        }.bind(this));
      }
    }.bind(this), 1 / cc.game.getFrameRate(), 1); // 加个塔顶
 
    gcore.Timer.set(function () {
      if (this.top_bg == null) {
        var y = this.cellList[number - 1].y + this.item_height;
        this.top_bg = Utils.createImage(this.container, null, this.start_x + this.item_width * 0.5 - 10, y, cc.v2(0.5, 0), false, 3, false);
        LoaderManager.getInstance().loadRes(PathTool.getBigBg("bigbg_29"), function (resObject) {
          this.top_bg.spriteFrame = resObject;
          this.moveToArrowNewPosition();
        }.bind(this));
      }
    }.bind(this), 2 / cc.game.getFrameRate(), 1);
    this.moveToArrowNewPosition();
    gcore.Timer.set(function () {
      //显示人物箭头
      this.moveToArrowNewPosition();
    }.bind(this), 3 / cc.game.getFrameRate(), 1);
  },
  jumpToMoveByY: function jumpToMoveByY(y) {
    if (!y) return;
    var pos = y - this.size.height * 0.5;
 
    if (pos < 0) {
      pos = 0;
    }
 
    var pos_per = pos / (this.container_size.height - this.size.height);
 
    if (pos_per > 1) {
      pos_per = 1;
    }
 
    if (pos_per == 1) {
      this.checkOverShowByVertical();
    }
 
    this.scroll_view_compend.scrollToPercentVertical(pos_per, 0.5, true);
  },
  // -----------------------中间背景的代码开始-----------------------------------------------------------
  updateBgList: function updateBgList() {
    if (this.scroll_view_bg == null) {
      var height = this.container_size.height / this.bg_param;
      var scroll_view_size = this.size; // var scale = display.getMaxScale();
 
      var bg_height = 955; //循环图的高度  * scale
 
      this.bg_max_count = Math.ceil(height / bg_height) + 1;
      var list_setting = {
        start_x: 0,
        space_x: 0,
        start_y: 322,
        space_y: 0,
        item_width: 720 * FIT_SCALE,
        item_height: bg_height,
        row: 0,
        col: 1
      };
      this.scroll_view_bg = new CommonScrollViewSingleLayout();
      this.scroll_view_bg.createScroll(this.root_wnd, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.bottom, scroll_view_size, list_setting, cc.v2(0.5, 0));
      this.scroll_view_bg.time_show_index = this.bg_max_count + 1;
      this.scroll_view_bg.registerScriptHandlerSingle(this.createNewCellBg.bind(this), ScrollViewFuncType.CreateNewCell); //创建cell
 
      this.scroll_view_bg.registerScriptHandlerSingle(this.numberOfCellsBg.bind(this), ScrollViewFuncType.NumberOfCells); //获取数量
      // -- this.scroll_view_bg:registerScriptHandlerSingle(this.updateCellByIndexBg.bind(this), ScrollViewFuncType.UpdateCellByIndex) --更新cell
      // -- this.scroll_view:registerScriptHandlerSingle(this.onCellTouched.bind(this), ScrollViewFuncType.OnCellTouched) --更新cell
 
      this.scroll_view_bg.setClickEnabled(false); // -- var bottom_bg_height = 322 --底部一张固定图的高度
    }
 
    this.scroll_view_bg.reloadData();
  },
  // 创建cell 
  createNewCellBg: function createNewCellBg() {
    if (this.scroll_view_bg && this.scroll_view_bottom_bg == null) {
      gcore.Timer.set(function () {
        if (this.scroll_view_bottom_bg == null) {
          var container = this.scroll_view_bg.getContainer();
          this.scroll_view_bottom_bg = Utils.createImage(container, null, this.container_size.width / 2, 0, cc.v2(0.5, 0), false, 1, false);
          this.scroll_view_bottom_bg.node.scaleX = 2 * FIT_SCALE;
          this.scroll_view_bottom_bg.node.scaleY = 2;
          LoaderManager.getInstance().loadRes(PathTool.getBigBg("bigbg_27"), function (resObject) {
            this.scroll_view_bottom_bg.spriteFrame = resObject;
          }.bind(this));
        }
      }.bind(this), 3 / cc.game.getFrameRate(), 1);
    }
 
    var cell = Utils.createImage(null, null, null, null, cc.v2(0.5, 0.5), false, 0, false);
    cell.node.scaleY = 2;
    cell.node.scaleX = 2 * FIT_SCALE;
    LoaderManager.getInstance().loadRes(PathTool.getBigBg("bigbg_36"), function (resObject) {
      cell.spriteFrame = resObject;
    }.bind(this)); // cell.setScale(display.getMaxScale())
 
    return cell.node;
  },
  // 获取数据数量
  numberOfCellsBg: function numberOfCellsBg() {
    return this.bg_max_count || 0;
  },
  // -----------------------中间背景的代码结束-----------------------------------------------------------
  // 移动人物箭头到最新位置
  moveToArrowNewPosition: function moveToArrowNewPosition() {
    var index = StartowerController.getInstance().getModel().getNowTowerId() || 0;
    var cellData = this.cellList[index];
    if (!cellData) return;
    this.jumpToMoveByY(cellData.y);
    this.setNowArrowPos();
  },
  setNowArrowPos: function setNowArrowPos() {
    if (!this.arrow_btn) return;
    var index = StartowerController.getInstance().getModel().getNowTowerId() || 0;
    index = index + 1;
    var number = this.numberOfCells();
 
    if (index > number) {
      index = number;
    }
 
    var cellData = this.cellList[index];
    if (!cellData) return;
    var x = cellData.x + this.item_width - 5;
    var y = cellData.y + this.item_height * 0.5;
    this.arrow_height = y;
    this.arrow_btn.setPosition(x, y);
  },
  // 箭头逻辑
  // @top 当前this.container对应屏幕 的顶部 y位置
  // @bot 当前this.container对应屏幕 的底部 y位置
  updateArrowPos: function updateArrowPos(top, bot) {
    if (!this.arrow_height) return;
    var top_param = 140;
    var bot_param = 245;
 
    if (top - top_param <= this.arrow_height) {
      this.arrow_btn.y = top - top_param;
    } else if (bot + bot_param >= this.arrow_height) {
      this.arrow_btn.y = bot + bot_param;
    } else {
      this.arrow_btn.y = this.arrow_height;
    }
  },
  // 选中index索引对象(如果列表允许 会排序在开始第一位)
  selectCellByIndex: function selectCellByIndex(index) {
    // 一屏幕显示的最大数量
    var maxRefreshNum = this.cacheMaxSize - this.col;
    var number = this.numberOfCells();
 
    if (number < maxRefreshNum) {
      // 不够显示一屏幕
      for (var i = 0; i < number; i++) {
        this.updateCellAtIndex(i);
        this.activeCellIdx[i] = true;
      }
    } else {
      var container_y;
 
      if (index <= 1) {
        container_y = 0;
      } else {
        container_y = this.cellList[index].y + this.item_height - this.size.height * 0.5;
      }
 
      if (container_y < 0) {
        container_y = 0;
      }
 
      this.container.y = -container_y;
      this.checkOverShowByVertical();
    } // -- if index > 0 and index <= this:numberOfCells() then
    // --     var cell = this:getCacheCellByIndex(index)
    // --     cell.index = index
    // --     this.cellList[index].cell = cell
    // --     this:onCellTouched(cell, index)
    // -- end 
 
  },
  // 获取index 对应的位置 由于一开始不创建item  
  // @return 是[index]对象所在的中点
  getCellPosition: function getCellPosition(index) {
    var anchor_point = cc.v2(0, 0);
 
    var _x = this.start_x + this.item_width * anchor_point.x + (this.item_width + this.space_x) * ((index - 1) % this.col);
 
    var _y = this.start_y + this.item_height * anchor_point.y + Math.floor((index - 1) / this.col) * (this.item_height + this.space_y);
 
    return {
      x: _x,
      y: _y
    };
  },
  // 获得格子下标对应的缓存itemCell
  getCacheCellByIndex: function getCacheCellByIndex(index) {
    var cacheIndex = index % this.cacheMaxSize;
 
    if (!this.cacheList[cacheIndex]) {
      var newCell = this.createNewCell();
 
      if (newCell) {
        newCell.setAnchorPoint(0, 0);
        newCell.setPosition(-10000, 0); //隐藏
 
        this.cacheList[cacheIndex] = newCell;
        newCell.setParent(this.container);
      }
 
      return newCell;
    } else {
      return this.cacheList[cacheIndex];
    }
  },
  // 更新格子,并记为活跃
  updateCellAtIndex: function updateCellAtIndex(index) {
    if (!this.cellList[index]) return;
    var cellData = this.cellList[index];
    cellData.cell.setPosition(cellData.x, cellData.y);
    this.updateCellByIndex(cellData.cell, index);
  },
  getMaxSize: function getMaxSize() {
    return this.container_size;
  },
  getContainer: function getContainer() {
    return this.container;
  },
  deleteMe: function deleteMe() {
    this.DeleteMe();
  },
  //移除对象
  DeleteMe: function DeleteMe() {
    // doStopAllActions(this)
    // doStopAllActions(this.container)
    if (this.head) {
      this.head.deleteMe();
      this.head = null;
    }
 
    for (var i in this.cacheList) {
      if (this.cacheList[i].onDelete) {
        this.cacheList[i].onDelete();
      }
    }
 
    if (this.scroll_view_bg) {
      this.scroll_view_bg.deleteMe();
      this.scroll_view_bg = null;
    }
 
    this.cellList = null;
    this.activeCellIdx = null;
    this.cacheList = null; // this:removeAllChildren()
    // this:removeFromParent()
  }
});
 
cc._RF.pop();