新增poolcomponent 对象池组件

This commit is contained in:
yhh
2020-06-30 22:22:52 +08:00
parent 099aa749e1
commit 088891c5ca
11 changed files with 217 additions and 60 deletions

View File

@@ -23,6 +23,15 @@ class MainScene extends Scene {
player2.addComponent(new BoxCollider());
}
let pool = new ComponentPool<SimplePooled>(SimplePooled);
let c1 = pool.obtain();
let c2 = pool.obtain();
pool.free(c1);
let c1b = pool.obtain();
console.log(c1 != c2);
console.log(c1 == c1b);
let button = new eui.Button();
button.label = "切换场景";
this.addChild(button);

View File

@@ -0,0 +1,5 @@
class SimplePooled extends PooledComponent {
public reset(){
}
}