- Creator 版本:1.9
请问Typescript如何传入对象池的处理组件参数,js文档里是这样
let menuItemPool = new cc.NodePool('MenuItem');
直接传入了字符串名称,来调用那个组件。
可我在ts中这么写,没有生效。
这是TS中对于该参数的注释
constructor(poolHandlerComp?: {prototype: Component}|string);
/** !#en The pool handler component, it could be the class name or the constructor.
!#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
poolHandlerComp: Function|string;
这是我创建对象池的代码
//制造对象池
this.nodePool = new cc.NodePool('PlanetNodePool');
这是我希望可以绑定上的组件
文件的名字是PlanetNodePool .ts,不是js文件
export default class PlanetNodePool extends cc.Component {
unuse(){
cc.log("QAQ");
};
reuse(){
cc.log("AQA")
}
}
