- 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 -.-
regards
casp0or
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);
}
casp0or
