add alpha config for myst-ec sprites

This commit is contained in:
Felix Staud 2024-07-10 20:54:55 -07:00
parent 81112eeabe
commit 5ff1ae617d

View File

@ -90,32 +90,34 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
const spacingValue = Math.round((maxX - minX) / Math.max(this.spriteConfigs.filter(s => !s.x && !s.y).length, 1)); const spacingValue = Math.round((maxX - minX) / Math.max(this.spriteConfigs.filter(s => !s.x && !s.y).length, 1));
this.spriteConfigs?.forEach((config) => { this.spriteConfigs?.forEach((config) => {
const { spriteKey, isItem, hasShadow, scale, x, y, alpha } = config;
let sprite: GameObjects.Sprite; let sprite: GameObjects.Sprite;
let tintSprite: GameObjects.Sprite; let tintSprite: GameObjects.Sprite;
if (!config.isItem) { if (!isItem) {
sprite = getSprite(config.spriteKey, config.hasShadow); sprite = getSprite(spriteKey, hasShadow);
tintSprite = getSprite(config.spriteKey); tintSprite = getSprite(spriteKey);
} else { } else {
sprite = getItemSprite(config.spriteKey); sprite = getItemSprite(spriteKey);
tintSprite = getItemSprite(config.spriteKey); tintSprite = getItemSprite(spriteKey);
} }
tintSprite.setVisible(false); tintSprite.setVisible(false);
if (config.scale) { if (scale) {
sprite.setScale(config.scale); sprite.setScale(scale);
tintSprite.setScale(config.scale); tintSprite.setScale(scale);
} }
// Sprite offset from origin // Sprite offset from origin
if (config.x || config.y) { if (x || y) {
if (config.x) { if (x) {
sprite.setPosition(origin + config.x, sprite.y); sprite.setPosition(origin + x, sprite.y);
tintSprite.setPosition(origin + config.x, tintSprite.y); tintSprite.setPosition(origin + x, tintSprite.y);
} }
if (config.y) { if (y) {
sprite.setPosition(sprite.x, config.y); sprite.setPosition(sprite.x, y);
tintSprite.setPosition(tintSprite.x, config.y); tintSprite.setPosition(tintSprite.x, y);
} }
} else { } else {
// Single sprite // Single sprite
@ -130,6 +132,11 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
} }
} }
if (alpha) {
sprite.setAlpha(alpha);
tintSprite.setAlpha(alpha);
}
this.add(sprite); this.add(sprite);
this.add(tintSprite); this.add(tintSprite);
}); });