fix anmation duplicate warnings

This commit is contained in:
Matthew Olker 2024-05-24 22:57:28 -04:00
parent 32fadf8cb6
commit 1e283afc84
7 changed files with 72 additions and 54 deletions

View File

@ -630,13 +630,15 @@ export class TrainerConfig {
? scene.anims.generateFrameNames(partnerTrainerKey, {zeroPad: 4,suffix: ".png",start: 1,end: 128}) ? scene.anims.generateFrameNames(partnerTrainerKey, {zeroPad: 4,suffix: ".png",start: 1,end: 128})
: null; : null;
console.warn = originalWarn; console.warn = originalWarn;
scene.anims.create({ if (!(scene.anims.exists(trainerKey))) {
key: trainerKey, scene.anims.create({
frames: frameNames, key: trainerKey,
frameRate: 24, frames: frameNames,
repeat: -1 frameRate: 24,
}); repeat: -1
if (isDouble) { });
}
if (isDouble && !(scene.anims.exists(partnerTrainerKey))) {
scene.anims.create({ scene.anims.create({
key: partnerTrainerKey, key: partnerTrainerKey,
frames: partnerFrameNames, frames: partnerFrameNames,

View File

@ -24,12 +24,14 @@ export function addPokeballOpenParticles(scene: BattleScene, x: number, y: numbe
function doDefaultPbOpenParticles(scene: BattleScene, x: number, y: number, radius: number) { function doDefaultPbOpenParticles(scene: BattleScene, x: number, y: number, radius: number) {
const pbOpenParticlesFrameNames = scene.anims.generateFrameNames("pb_particles", { start: 0, end: 3, suffix: ".png" }); const pbOpenParticlesFrameNames = scene.anims.generateFrameNames("pb_particles", { start: 0, end: 3, suffix: ".png" });
scene.anims.create({ if (!(scene.anims.exists("pb_open_particle"))) {
key: "pb_open_particle", scene.anims.create({
frames: pbOpenParticlesFrameNames, key: "pb_open_particle",
frameRate: 16, frames: pbOpenParticlesFrameNames,
repeat: -1 frameRate: 16,
}); repeat: -1
});
}
const addParticle = (index: integer) => { const addParticle = (index: integer) => {
const particle = scene.add.sprite(x, y, "pb_open_particle"); const particle = scene.add.sprite(x, y, "pb_open_particle");

View File

@ -726,12 +726,14 @@ export class ArenaBase extends Phaser.GameObjects.Container {
if (this.base.texture.frameTotal > 1) { if (this.base.texture.frameTotal > 1) {
const baseFrameNames = this.scene.anims.generateFrameNames(baseKey, { zeroPad: 4, suffix: ".png", start: 1, end: this.base.texture.frameTotal - 1 }); const baseFrameNames = this.scene.anims.generateFrameNames(baseKey, { zeroPad: 4, suffix: ".png", start: 1, end: this.base.texture.frameTotal - 1 });
this.scene.anims.create({ if (!(this.scene.anims.exists(baseKey))) {
key: baseKey, this.scene.anims.create({
frames: baseFrameNames, key: baseKey,
frameRate: 12, frames: baseFrameNames,
repeat: -1 frameRate: 12,
}); repeat: -1
});
}
this.base.play(baseKey); this.base.play(baseKey);
} else { } else {
this.base.stop(); this.base.stop();
@ -751,12 +753,14 @@ export class ArenaBase extends Phaser.GameObjects.Container {
if (hasProps && prop.texture.frameTotal > 1) { if (hasProps && prop.texture.frameTotal > 1) {
const propFrameNames = this.scene.anims.generateFrameNames(propKey, { zeroPad: 4, suffix: ".png", start: 1, end: prop.texture.frameTotal - 1 }); const propFrameNames = this.scene.anims.generateFrameNames(propKey, { zeroPad: 4, suffix: ".png", start: 1, end: prop.texture.frameTotal - 1 });
this.scene.anims.create({ if (!(this.scene.anims.exists(propKey))) {
key: propKey, this.scene.anims.create({
frames: propFrameNames, key: propKey,
frameRate: 12, frames: propFrameNames,
repeat: -1 frameRate: 12,
}); repeat: -1
});
}
prop.play(propKey); prop.play(propKey);
} else { } else {
prop.stop(); prop.stop();

View File

@ -322,12 +322,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
console.warn = () => {}; console.warn = () => {};
const battleFrameNames = this.scene.anims.generateFrameNames(this.getBattleSpriteKey(), { zeroPad: 4, suffix: ".png", start: 1, end: 400 }); const battleFrameNames = this.scene.anims.generateFrameNames(this.getBattleSpriteKey(), { zeroPad: 4, suffix: ".png", start: 1, end: 400 });
console.warn = originalWarn; console.warn = originalWarn;
this.scene.anims.create({ if (!(this.scene.anims.exists(this.getBattleSpriteKey()))) {
key: this.getBattleSpriteKey(), this.scene.anims.create({
frames: battleFrameNames, key: this.getBattleSpriteKey(),
frameRate: 12, frames: battleFrameNames,
repeat: -1 frameRate: 12,
}); repeat: -1
});
}
} }
this.playAnim(); this.playAnim();
const updateFusionPaletteAndResolve = () => { const updateFusionPaletteAndResolve = () => {
@ -524,13 +526,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
shinySparkle.setVisible(false); shinySparkle.setVisible(false);
shinySparkle.setOrigin(0.5, 1); shinySparkle.setOrigin(0.5, 1);
const frameNames = this.scene.anims.generateFrameNames(key, { suffix: ".png", end: 34 }); const frameNames = this.scene.anims.generateFrameNames(key, { suffix: ".png", end: 34 });
this.scene.anims.create({ if (!(this.scene.anims.exists(`sparkle${keySuffix}`))) {
key: `sparkle${keySuffix}`, this.scene.anims.create({
frames: frameNames, key: `sparkle${keySuffix}`,
frameRate: 32, frames: frameNames,
showOnStart: true, frameRate: 32,
hideOnComplete: true, showOnStart: true,
}); hideOnComplete: true,
});
}
this.add(shinySparkle); this.add(shinySparkle);
this.shinySparkle = shinySparkle; this.shinySparkle = shinySparkle;

View File

@ -4411,7 +4411,7 @@ export class PokemonHealPhase extends CommonAnimPhase {
} }
const healAmount = new Utils.NumberHolder(Math.floor(this.hpHealed * hpRestoreMultiplier.value)); const healAmount = new Utils.NumberHolder(Math.floor(this.hpHealed * hpRestoreMultiplier.value));
if (healAmount.value < 0) { if (healAmount.value < 0) {
pokemon.damageAndUpdate(healAmount.value * -1, HitResult.HEAL); pokemon.damageAndUpdate(healAmount.value * -1, HitResult.HEAL as DamageResult);
healAmount.value = 0; healAmount.value = 0;
} }
// Prevent healing to full if specified (in case of healing tokens so Sturdy doesn't cause a softlock) // Prevent healing to full if specified (in case of healing tokens so Sturdy doesn't cause a softlock)

View File

@ -61,16 +61,20 @@ export default class EggGachaUiHandler extends MessageUiHandler {
this.eggGachaContainer.add(bg); this.eggGachaContainer.add(bg);
const hatchFrameNames = this.scene.anims.generateFrameNames("gacha_hatch", { suffix: ".png", start: 1, end: 4 }); const hatchFrameNames = this.scene.anims.generateFrameNames("gacha_hatch", { suffix: ".png", start: 1, end: 4 });
this.scene.anims.create({ if (!(this.scene.anims.exists("open"))) {
key: "open", this.scene.anims.create({
frames: hatchFrameNames, key: "open",
frameRate: 12 frames: hatchFrameNames,
}); frameRate: 12
this.scene.anims.create({ });
key: "close", }
frames: hatchFrameNames.reverse(), if (!(this.scene.anims.exists("close"))) {
frameRate: 12 this.scene.anims.create({
}); key: "close",
frames: hatchFrameNames.reverse(),
frameRate: 12
});
}
Utils.getEnumValues(GachaType).forEach((gachaType, g) => { Utils.getEnumValues(GachaType).forEach((gachaType, g) => {
const gachaTypeKey = GachaType[gachaType].toString().toLowerCase(); const gachaTypeKey = GachaType[gachaType].toString().toLowerCase();

View File

@ -16,11 +16,13 @@ export default class EggHatchSceneHandler extends UiHandler {
this.scene.fieldUI.add(this.eggHatchContainer); this.scene.fieldUI.add(this.eggHatchContainer);
const eggLightraysAnimFrames = this.scene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 }); const eggLightraysAnimFrames = this.scene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 });
this.scene.anims.create({ if (!(this.scene.anims.exists("egg_lightrays"))) {
key: "egg_lightrays", this.scene.anims.create({
frames: eggLightraysAnimFrames, key: "egg_lightrays",
frameRate: 32 frames: eggLightraysAnimFrames,
}); frameRate: 32
});
}
} }
show(_args: any[]): boolean { show(_args: any[]): boolean {