Fix issues with Pokemon sprites persisting after some moves

pull/2/head
Flashfyre 2023-10-22 10:13:03 -04:00
parent 7c5d7074ec
commit e0065fca7c
1 changed files with 8 additions and 5 deletions

View File

@ -760,12 +760,15 @@ export abstract class BattleAnim {
for (let i of targets) { for (let i of targets) {
const count = i === AnimFrameTarget.GRAPHIC ? g : i === AnimFrameTarget.USER ? u : t; const count = i === AnimFrameTarget.GRAPHIC ? g : i === AnimFrameTarget.USER ? u : t;
if (count < spriteCache[i].length) { if (count < spriteCache[i].length) {
const removedSprites = spriteCache[i].splice(count, spriteCache[i].length - count); const spritesToRemove = spriteCache[i].slice(count, spriteCache[i].length);
if (i === AnimFrameTarget.GRAPHIC) for (let rs of spritesToRemove) {
spritePriorities.splice(count, spriteCache[i].length - count); if (!rs.getData('locked') as boolean) {
for (let rs of removedSprites) { const spriteCacheIndex = spriteCache[i].indexOf(rs);
if (!rs.getData('locked') as boolean) spriteCache[i].splice(spriteCacheIndex, 1);
if (i === AnimFrameTarget.GRAPHIC)
spritePriorities.splice(spriteCacheIndex, 1);
rs.destroy(); rs.destroy();
}
} }
} }
} }