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})
: null;
console.warn = originalWarn;
scene.anims.create({
key: trainerKey,
frames: frameNames,
frameRate: 24,
repeat: -1
});
if (isDouble) {
if (!(scene.anims.exists(trainerKey))) {
scene.anims.create({
key: trainerKey,
frames: frameNames,
frameRate: 24,
repeat: -1
});
}
if (isDouble && !(scene.anims.exists(partnerTrainerKey))) {
scene.anims.create({
key: partnerTrainerKey,
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) {
const pbOpenParticlesFrameNames = scene.anims.generateFrameNames("pb_particles", { start: 0, end: 3, suffix: ".png" });
scene.anims.create({
key: "pb_open_particle",
frames: pbOpenParticlesFrameNames,
frameRate: 16,
repeat: -1
});
if (!(scene.anims.exists("pb_open_particle"))) {
scene.anims.create({
key: "pb_open_particle",
frames: pbOpenParticlesFrameNames,
frameRate: 16,
repeat: -1
});
}
const addParticle = (index: integer) => {
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) {
const baseFrameNames = this.scene.anims.generateFrameNames(baseKey, { zeroPad: 4, suffix: ".png", start: 1, end: this.base.texture.frameTotal - 1 });
this.scene.anims.create({
key: baseKey,
frames: baseFrameNames,
frameRate: 12,
repeat: -1
});
if (!(this.scene.anims.exists(baseKey))) {
this.scene.anims.create({
key: baseKey,
frames: baseFrameNames,
frameRate: 12,
repeat: -1
});
}
this.base.play(baseKey);
} else {
this.base.stop();
@ -751,12 +753,14 @@ export class ArenaBase extends Phaser.GameObjects.Container {
if (hasProps && 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({
key: propKey,
frames: propFrameNames,
frameRate: 12,
repeat: -1
});
if (!(this.scene.anims.exists(propKey))) {
this.scene.anims.create({
key: propKey,
frames: propFrameNames,
frameRate: 12,
repeat: -1
});
}
prop.play(propKey);
} else {
prop.stop();

View File

@ -322,12 +322,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
console.warn = () => {};
const battleFrameNames = this.scene.anims.generateFrameNames(this.getBattleSpriteKey(), { zeroPad: 4, suffix: ".png", start: 1, end: 400 });
console.warn = originalWarn;
this.scene.anims.create({
key: this.getBattleSpriteKey(),
frames: battleFrameNames,
frameRate: 12,
repeat: -1
});
if (!(this.scene.anims.exists(this.getBattleSpriteKey()))) {
this.scene.anims.create({
key: this.getBattleSpriteKey(),
frames: battleFrameNames,
frameRate: 12,
repeat: -1
});
}
}
this.playAnim();
const updateFusionPaletteAndResolve = () => {
@ -524,13 +526,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
shinySparkle.setVisible(false);
shinySparkle.setOrigin(0.5, 1);
const frameNames = this.scene.anims.generateFrameNames(key, { suffix: ".png", end: 34 });
this.scene.anims.create({
key: `sparkle${keySuffix}`,
frames: frameNames,
frameRate: 32,
showOnStart: true,
hideOnComplete: true,
});
if (!(this.scene.anims.exists(`sparkle${keySuffix}`))) {
this.scene.anims.create({
key: `sparkle${keySuffix}`,
frames: frameNames,
frameRate: 32,
showOnStart: true,
hideOnComplete: true,
});
}
this.add(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));
if (healAmount.value < 0) {
pokemon.damageAndUpdate(healAmount.value * -1, HitResult.HEAL);
pokemon.damageAndUpdate(healAmount.value * -1, HitResult.HEAL as DamageResult);
healAmount.value = 0;
}
// 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);
const hatchFrameNames = this.scene.anims.generateFrameNames("gacha_hatch", { suffix: ".png", start: 1, end: 4 });
this.scene.anims.create({
key: "open",
frames: hatchFrameNames,
frameRate: 12
});
this.scene.anims.create({
key: "close",
frames: hatchFrameNames.reverse(),
frameRate: 12
});
if (!(this.scene.anims.exists("open"))) {
this.scene.anims.create({
key: "open",
frames: hatchFrameNames,
frameRate: 12
});
}
if (!(this.scene.anims.exists("close"))) {
this.scene.anims.create({
key: "close",
frames: hatchFrameNames.reverse(),
frameRate: 12
});
}
Utils.getEnumValues(GachaType).forEach((gachaType, g) => {
const gachaTypeKey = GachaType[gachaType].toString().toLowerCase();

View File

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