Ulter Posted August 25, 2017 Share Posted August 25, 2017 I have a function to create shells Quote function fire() { if (game.time.now > nextFire && bullets.countDead() > 0) { nextFire = game.time.now + fireRate; weapon.push(game.add.sprite(player.x - -15, player.y - -5, 'bullet')); game.physics.enable(weapon[n], Phaser.Physics.ARCADE); weapon[n].body.velocity.x = 500; n++; shooting_sound.play(); if (t_destroy_bull_status == 1) { countdown_timer_destoy_bullet(); } //for (weapon[a]; 2 <= weapon[a]; a--) { var nnn = 0; weapon[nnn].destroy(); nnn++; console.log("n_f:::"); } } I need to delete all the created shells, after a while, after their creation. But I can not do it Link to comment Share on other sites More sharing options...
Ulter Posted August 25, 2017 Author Share Posted August 25, 2017 Quote function countdown_timer_destoy_bullet() { t_destroy_bull_status = 0; t_destroy_bull = game.time.create(false); t_destroy_bull.add(500, destoy_bullet); t_destroy_bull.start(); } function destoy_bullet() { //console.log(44, "destoy_bullet", 5555555555544444, "destoy_bullet", 55555554444); //var item = []; //var n_item = 0; //item.push(for_arg); //item[n_item] = weapon[n]; //var item = for_arg; /*var n_db = 1; delete weapon[weapon.length - n_db]; n_db ++;*/ //var item; //item = weapon[weapon.length - 1]; /*if (item) { item.kill(); //n_item++; //console.log(item); }*/ //else var rrr = weapon.length; console.log("rrr: ", rrr); var rr = weapon[weapon.length - 1] //console.log("rr: ", rr); nn++; weapon[weapon.length - nn].destroy(); while (weapon[weapon.length] >= 1) { var n_f = 0; weapon[weapon.length - n_f].destroy(); n_f++; console.log("n_f:::"); } /*else { //n_db = 1; t_destroy_bull_status = 1; nn = 1; }*/ } Here I am also so indulged Link to comment Share on other sites More sharing options...
Recommended Posts