So I'm basically trying to make a way to add enemies to a troop DURING a battle. From a mechanic standpoint, it's working perfectly. The problem is the new enemy's sprite won't show up, which also messes with targeting and spell animations for that enemy.
Basically, when I finish adding the enemy to the troop, I call the Battlemanager.refreshEnemies, which refreshes the sprite set. I've tested the clearing of the old sprites, that part works (I think. It throws an error if left by itself, which tells me that code IS being reach and executed). But after clearing the old sprites, I call the built-in function createEnemies, which is supposed to draw ALL the troop members (and the console tells me the new enemies ARE being added to the troop members). But it only redraws the original enemies, and not the new ones.
I'm not graphically inclined, so graphic-related code makes my head spin, but since the function DOES redraw the original troop sprites, I know at least that part of it is working, I'm just apparently screwing up the "draw the new ones too" part. Does anyone happen to have any thoughts on where I'm messing up, or perhaps can point me in the right direction to look? Thanks in advance!
JavaScript:
BattleManager.refreshEnemies = function() {
this._spriteset.refresh();
};
Spriteset_Battle.prototype.refresh = function() {
var sprites = this._enemySprites;
for (i = 0; i < sprites.length; i++) {
this._battleField.removeChild(sprites[i]);
};
this.createEnemies();
};
Basically, when I finish adding the enemy to the troop, I call the Battlemanager.refreshEnemies, which refreshes the sprite set. I've tested the clearing of the old sprites, that part works (I think. It throws an error if left by itself, which tells me that code IS being reach and executed). But after clearing the old sprites, I call the built-in function createEnemies, which is supposed to draw ALL the troop members (and the console tells me the new enemies ARE being added to the troop members). But it only redraws the original enemies, and not the new ones.
I'm not graphically inclined, so graphic-related code makes my head spin, but since the function DOES redraw the original troop sprites, I know at least that part of it is working, I'm just apparently screwing up the "draw the new ones too" part. Does anyone happen to have any thoughts on where I'm messing up, or perhaps can point me in the right direction to look? Thanks in advance!