代码拉取完成,页面将自动刷新
const NodePool = require('NodePool');
const FoeType = require('Types').FoeType;
const ProjectileType = require('Types').ProjectileType;
cc.Class({
extends: cc.Component,
properties: {
foePools: {
default: [],
type: NodePool
},
projectilePools: {
default: [],
type: NodePool
}
},
// use this for initialization
init () {
for (let i = 0; i < this.foePools.length; ++i) {
this.foePools[i].init();
}
for (let i = 0; i < this.projectilePools.length; ++i) {
this.projectilePools[i].init();
}
},
requestFoe (foeType) {
let thePool = this.foePools[foeType];
if (thePool.idx >= 0) {
return thePool.request();
} else {
return null;
}
},
returnFoe (foeType, obj) {
let thePool = this.foePools[foeType];
if (thePool.idx < thePool.size) {
thePool.return(obj);
} else {
cc.log('Return obj to a full pool, something has gone wrong');
return;
}
},
requestProjectile (type) {
let thePool = this.projectilePools[type];
if (thePool.idx >= 0) {
return thePool.request();
} else {
return null;
}
},
returnProjectile (type, obj) {
let thePool = this.projectilePools[type];
if (thePool.idx < thePool.size) {
thePool.return(obj);
} else {
cc.log('Return obj to a full pool, something has gone wrong');
return;
}
}
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。