xx 1 gadu atpakaļ
vecāks
revīzija
d072e4927d

+ 2 - 1
assets/script/framework/poolManager.ts

@@ -18,7 +18,7 @@ export class PoolManager {
 
 
     public isHavePool(prefab: Prefab):boolean{
     public isHavePool(prefab: Prefab):boolean{
         let name = prefab.name;
         let name = prefab.name;
-        if(this._dictPrefab[name]!=null){
+        if(this._dictPrefab[name]){
             return true;
             return true;
         }
         }
         return false;
         return false;
@@ -41,6 +41,7 @@ export class PoolManager {
             //已有对应的对象池
             //已有对应的对象池
             let pool = this._dictPool[name];
             let pool = this._dictPool[name];
             if (pool.size() > 0) {
             if (pool.size() > 0) {
+                console.log("is get pool?")
                 node = pool.get();
                 node = pool.get();
             } else {
             } else {
                 node = instantiate(prefab);
                 node = instantiate(prefab);

+ 5 - 8
assets/script/play_list/zhaocha_font/view_game_play_han_zi_zhao_bu_tong.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, instantiate, Label, Layout, Node, Prefab, ProgressBar, Sprite, SpriteFrame } from 'cc';
+import { _decorator, Component, Director, director, instantiate, Label, Layout, Node, Prefab, ProgressBar, Sprite, SpriteFrame } from 'cc';
 import { config } from '../../config';
 import { config } from '../../config';
 import { font_grid_pos, server_han_zi_zhao_bu_tong_data_item } from '../../data/server_play_list_data';
 import { font_grid_pos, server_han_zi_zhao_bu_tong_data_item } from '../../data/server_play_list_data';
 import { gameManager } from '../../gameManager';
 import { gameManager } from '../../gameManager';
@@ -67,7 +67,7 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
             })
             })
         },this);
         },this);
         if(!PoolManager.instance.isHavePool(this.item_prefab)){
         if(!PoolManager.instance.isHavePool(this.item_prefab)){
-            PoolManager.instance.preloadPool(this.item_prefab,11*15)
+            PoolManager.instance.preloadPool(this.item_prefab,this.m_data.col*this.m_data.row)
         }
         }
         
         
         ClientEvent.on(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER,this.onChangeCoinNumber.bind(this),this);
         ClientEvent.on(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER,this.onChangeCoinNumber.bind(this),this);
@@ -198,10 +198,6 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
     initGrid(){
     initGrid(){
         this.font_grid.getComponent(Layout).constraintNum = this.m_data.col;
         this.font_grid.getComponent(Layout).constraintNum = this.m_data.col;
         this.lab_coin.getComponent(Label).string = gameManager.get_user_coin()+"";
         this.lab_coin.getComponent(Label).string = gameManager.get_user_coin()+"";
-        for (let index = 0; index < this.font_grid.children.length; index++) {
-            const element = this.font_grid.children[index];
-            PoolManager.instance.putNode(element);
-        }
         this.font_grid.removeAllChildren()
         this.font_grid.removeAllChildren()
         this.bottom_pos.removeAllChildren()
         this.bottom_pos.removeAllChildren()
         this.left_pos.removeAllChildren()
         this.left_pos.removeAllChildren()
@@ -214,15 +210,16 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
             tools.showToast("关卡未配置数据!")
             tools.showToast("关卡未配置数据!")
             return
             return
         }
         }
+
         this.answer = JSON.parse(this.m_data.content);
         this.answer = JSON.parse(this.m_data.content);
         for (let index = 0; index <this.m_data.col*this.m_data.row; index++) {
         for (let index = 0; index <this.m_data.col*this.m_data.row; index++) {
             let col = index%this.m_data.col;
             let col = index%this.m_data.col;
             let row = Math.floor(index/this.m_data.col);
             let row = Math.floor(index/this.m_data.col);
-            // let item = instantiate(this.item_prefab);
             let item = PoolManager.instance.getNode(this.item_prefab,this.font_grid)
             let item = PoolManager.instance.getNode(this.item_prefab,this.font_grid)
             item.getComponent(font_grid_item).initView(this.default_img,this.find_img,row,col,this.onGridItemClick.bind(this),this.isRight(row,col));
             item.getComponent(font_grid_item).initView(this.default_img,this.find_img,row,col,this.onGridItemClick.bind(this),this.isRight(row,col));
-            // item.parent = this.font_grid;
+
         }
         }
+  
         for (let index = this.m_data.row; index > 0; index--) {
         for (let index = this.m_data.row; index > 0; index--) {
             let item = instantiate(this.left_item);
             let item = instantiate(this.left_item);
             item.parent = this.left_pos;
             item.parent = this.left_pos;