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;
if (!(scene.anims.exists(trainerKey))) {
scene.anims.create({ scene.anims.create({
key: trainerKey, key: trainerKey,
frames: frameNames, frames: frameNames,
frameRate: 24, frameRate: 24,
repeat: -1 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" });
if (!(scene.anims.exists("pb_open_particle"))) {
scene.anims.create({ scene.anims.create({
key: "pb_open_particle", key: "pb_open_particle",
frames: pbOpenParticlesFrameNames, frames: pbOpenParticlesFrameNames,
frameRate: 16, frameRate: 16,
repeat: -1 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 });
if (!(this.scene.anims.exists(baseKey))) {
this.scene.anims.create({ this.scene.anims.create({
key: baseKey, key: baseKey,
frames: baseFrameNames, frames: baseFrameNames,
frameRate: 12, frameRate: 12,
repeat: -1 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 });
if (!(this.scene.anims.exists(propKey))) {
this.scene.anims.create({ this.scene.anims.create({
key: propKey, key: propKey,
frames: propFrameNames, frames: propFrameNames,
frameRate: 12, frameRate: 12,
repeat: -1 repeat: -1
}); });
}
prop.play(propKey); prop.play(propKey);
} else { } else {
prop.stop(); prop.stop();

View File

@ -322,6 +322,7 @@ 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;
if (!(this.scene.anims.exists(this.getBattleSpriteKey()))) {
this.scene.anims.create({ this.scene.anims.create({
key: this.getBattleSpriteKey(), key: this.getBattleSpriteKey(),
frames: battleFrameNames, frames: battleFrameNames,
@ -329,6 +330,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
repeat: -1 repeat: -1
}); });
} }
}
this.playAnim(); this.playAnim();
const updateFusionPaletteAndResolve = () => { const updateFusionPaletteAndResolve = () => {
this.updateFusionPalette(); this.updateFusionPalette();
@ -524,6 +526,7 @@ 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 });
if (!(this.scene.anims.exists(`sparkle${keySuffix}`))) {
this.scene.anims.create({ this.scene.anims.create({
key: `sparkle${keySuffix}`, key: `sparkle${keySuffix}`,
frames: frameNames, frames: frameNames,
@ -531,6 +534,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
showOnStart: true, showOnStart: true,
hideOnComplete: 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 });
if (!(this.scene.anims.exists("open"))) {
this.scene.anims.create({ this.scene.anims.create({
key: "open", key: "open",
frames: hatchFrameNames, frames: hatchFrameNames,
frameRate: 12 frameRate: 12
}); });
}
if (!(this.scene.anims.exists("close"))) {
this.scene.anims.create({ this.scene.anims.create({
key: "close", key: "close",
frames: hatchFrameNames.reverse(), frames: hatchFrameNames.reverse(),
frameRate: 12 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,12 +16,14 @@ 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 });
if (!(this.scene.anims.exists("egg_lightrays"))) {
this.scene.anims.create({ this.scene.anims.create({
key: "egg_lightrays", key: "egg_lightrays",
frames: eggLightraysAnimFrames, frames: eggLightraysAnimFrames,
frameRate: 32 frameRate: 32
}); });
} }
}
show(_args: any[]): boolean { show(_args: any[]): boolean {
super.show(_args); super.show(_args);