can´t removeChild with more than 2 childs

casp0or

Villager
Member
Joined
Jan 10, 2017
Messages
12
Reaction score
0
First Language
German
Hi,

I am trying to add an enemy picture to my window, but also delete it from this window.

Adding is fine and deleting also ... but when i add a second enemy picture the second one gets deleted but the first one is not.

I have 5 enemy but only the last child is deleted -.-

Code:
    if(this._unitAdded[0].name != ""){
        this._enemy1 = new Sprite();
        this._enemy1.bitmap = ImageManager.loadEnemyPicture(this._unitAdded[0].name);
        this._enemy1.x = palceholder[0].x;
        this._enemy1.y = palceholder[0].y;
        this._enemy1_add = this.addChild(this._enemy1);
    }else if(this._enemy1){
        console.log("remove 1")
        //this._enemy1.opacity = 0;
        this.removeChild(this._enemy1);
        //this.removeChild(this._enemy1_add);
        //this._enemy1.bitmap = ImageManager.loadEnemyPicture("monster_empty");
    }

    if(this._unitAdded[1].name != ""){
        this._enemy2 = new Sprite();
        this._enemy2.bitmap = ImageManager.loadEnemyPicture(this._unitAdded[1].name);
        this._enemy2.x = palceholder[1].x;
        this._enemy2.y = palceholder[1].y;
        this._enemy2_add = this.addChildAt(this._enemy2);
    }else if(this._enemy2){
        console.log("remove 2")
        this.removeChild(this._enemy2);
    }
regards
casp0or
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top