Skip to content

Instantly share code, notes, and snippets.

@ruby0x1
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruby0x1/218decd48cc54890cc22 to your computer and use it in GitHub Desktop.
Save ruby0x1/218decd48cc54890cc22 to your computer and use it in GitHub Desktop.
luxe.structural.Pool example
//creation
var player_bullets : Pool<Sprite>;
player_bullets = new Pool<Sprite>(20,
function(index,total){
var _sprite = new Sprite({ pos: new Vector(-999,-999), visible:false });
var _projectile = _sprite.add( new Projectile({
bullet_type:'player'
}) );
return _sprite;
}
);
//use
function spawn() {
var bullet = player_bullets.get();
bullet.pos.copy_from(player.pos);
var projecile = bullet.get('projectile');
projectile.direction = player_direction;
projectile.spawn();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment