/*
 *  bulletlayer.js
 *  2015/11/12
 *  @auther minimo  
 *  This Program is MIT license.
 */

phina.define("pbr.BulletLayer", {
    superClass: "phina.display.CanvasElement",

    _member: {
        max: 256,
        pool : null,
    },

    init: function() {
        this.superInit();
        this.$extend(this._member);

        var self = this;
        this.pool = Array.range(0, this.max).map(function() {
            var b = pbr.Bullet();
            b.bulletLayer = self;
            return b;
        });
    },

    enterBullet: function(param) {
        var b = this.pool.shift();
        if (!b) {
            console.warn("Bullet empty!!");
            return null;
        }
        b.setup(param).addChildTo(this);
        return b;
    },

    //射出IDに合致する弾を消去（未指定時全消去）
    erace: function(id) {
        var all = (id === undefined? true: false);
        var list = this.children.slice();
        var len = list.length
        var b;
        for (var i = 0; i < len; i++) {
            b = list[i];
            b.erase();
            b.remove();
        }
    },
});

@@ -512,24 +512,34 @@
 %7D);%0A    %7D,%0A%0A
+    //%E5%BC%BE%E6%8A%95%E5%85%A5%0A
     enterBul
@@ -949,24 +949,47 @@
      var b;%0A
+        if (all) %7B%0A    
         for 
@@ -1028,16 +1028,20 @@
         
+   
+ 
 b = list
@@ -1057,16 +1057,20 @@
         
+    
 b.erase(
@@ -1084,16 +1084,20 @@
         
+   
+ 
 b.remove
@@ -1096,24 +1096,257 @@
 b.remove();%0A
+            %7D%0A        %7D else %7B%0A            for (var i = 0; i %3C len; i++) %7B%0A                b = list%5Bi%5D;%0A                if (id == b.id) %7B%0A                    b.erase();%0A                    b.remove();%0A                %7D%0A            %7D%0A
         %7D%0A  

add bullet erace