1 decade ago by doobdargent
Hi,
I just acquired ImpactJS and I love it!
I'm building a Shoot-em-up and because that kind of games use lots of entities, I built a simple BulletManager that return entities that can be re-used. (I was surprised that no plugins of this kind exists)
It's working. EntityBullets are created at init and I can use getAvailable() when needed.
The thing is the update() and draw() (maybe more) methods from the EntityBullets aren't called. I guess that's because Impact didn't add them to the ig.game.entities or something...
Any insight?
Cheers!
I just acquired ImpactJS and I love it!
I'm building a Shoot-em-up and because that kind of games use lots of entities, I built a simple BulletManager that return entities that can be re-used. (I was surprised that no plugins of this kind exists)
ig.module(
'game.bulletManager'
)
.requires(
'impact.entity',
'game.entities.bullet'
)
.defines(function(){
BulletManager = ig.Class.extend({
bullets: [],
outOfScreen: {x: -9999, y: -9999},
init: function(cacheSize){
this.bullets = new Array(cacheSize);
for(var i=0; i<this.bullets.length; i++){
this.bullets[i] = ig.game.spawnEntity(EntityBullet, this.outOfScreen.x, this.outOfScreen.y);
}
},
getAvailable: function(){
for(var i=0; i<this.bullets.length; i++){
if(this.bullets[i].isInactive()){
return this.bullets[i];
}
}
return null; // Send Exception
}
});
});
It's working. EntityBullets are created at init and I can use getAvailable() when needed.
The thing is the update() and draw() (maybe more) methods from the EntityBullets aren't called. I guess that's because Impact didn't add them to the ig.game.entities or something...
Any insight?
Cheers!
