いきなりループ書こうとすると難しいから、とりあえず並べてから後でまとめた。
すっきり。
if(this.touched && g.delay > 50){ for(var i=0; i<this.boms.length ;i++){ cc.log(i); if(this.boms[i].state == 0){ cc.log("hai>"); this.boms[i].state = 1; var bom = this.boms[i]; pos = cc.p(this.touched.x ,this.touched.y); //四角の中央に爆弾を設置する関数rectInPosition(); pos = this.rectInPosition(pos); bom.setPosition(pos); g.delay = 0; break; } } } if(this.boms[0].state == 0){ this.boms[0].state = 1; var bom = this.boms[0]; pos = cc.p(this.touched.x ,this.touched.y); //四角の中央に爆弾を設置する関数rectInPosition(); pos = this.rectInPosition(pos); bom.setPosition(pos); g.delay = 0; } else if (this.boms[1].state == 0){ this.boms[1].state = 1; var bom = this.boms[1]; pos = cc.p(this.touched.x ,this.touched.y); pos = this.rectInPosition(pos); bom.setPosition(pos); g.delay = 0; } else if (this.boms[2].state == 0){ this.boms[2].state = 1; var bom = this.boms[2]; pos = cc.p(this.touched.x ,this.touched.y); pos = this.rectInPosition(pos); bom.setPosition(pos); bom.state = 1; g.delay = 0; } else{ this.boms[3].state = 1; var bom = this.boms[3]; pos = cc.p(this.touched.x ,this.touched.y); pos = this.rectInPosition(pos); bom.setPosition(pos); bom.state = 1; g.delay = 0; }