4 Star 7 Fork 6

mirrors_cocos-creator / tutorial-dark-slash

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
PoolMng.js 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
Wang Nan 提交于 2016-03-08 19:35 . add death and gameover menu ui.
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;
}
}
});
1
https://gitee.com/mirrors_cocos-creator/tutorial-dark-slash.git
git@gitee.com:mirrors_cocos-creator/tutorial-dark-slash.git
mirrors_cocos-creator
tutorial-dark-slash
tutorial-dark-slash
master

搜索帮助