Permalink
Browse files

Added facility to delete sprites from scene.

  • Loading branch information...
1 parent af9d066 commit cfc7691f49d6a4b3d2efb2d35dd22b1b834ac1e0 @MalphasWats committed Jan 26, 2015
Showing with 7 additions and 2 deletions.
  1. +7 −2 glixl.js
View
@@ -151,7 +151,12 @@ var glixl = (function(glixl)
glixl.Scene.prototype.add_sprite = function(sprite)
{
- this.sprites.push(sprite);
+ sprite.scene_index = this.sprites.push(sprite) - 1;
+ }
+
+ glixl.Scene.prototype.remove_sprite = function(sprite)
+ {
+ delete this.sprites[sprite.scene_index];
}
glixl.Scene.prototype.set_active_tilemap = function(tilemap)
@@ -208,7 +213,7 @@ var glixl = (function(glixl)
for(var i=0 ; i<this.sprites.length ; i++)
{
- if (this.is_visible(this.sprites[i]))
+ if (this.sprites[i] && this.is_visible(this.sprites[i]))
this.sprites[i].render();
}
this.redraw = false;

0 comments on commit cfc7691

Please sign in to comment.