Hey everyone,
I've been playing around in MV again, trying some things out. This request is inspired by SNES games like Chrono Trigger and FF6 when a character casts a spell, or uses a skill, the battle background darkens with what's like a 50% black transparent overlay or is just tinted darker in a similar way. The darkening fades in just prior to the spell animation, and fades back to default tinting when the spell animation is over. It only affects the background, not the sprites or any other graphical elements on the screen.
One idea for implementation would be that this effect could be applied to skills in the database that have the <isDarkened> tag. It's an idea anyway. I know PixiJS does a lot of graphical things, so maybe using that could help?
I HAVE tried using ChatGPT to help me out (don't judge me), as I'm not a programmer. There's been some mild success after hours of tweaking, but only in applying a darkly tinted effect to the background (is just there at the beginning of battle and persists).
If anyone could help me out or point me in the right direction, it would be much appreciated. Thanks!
For reference, here's a thing ChatGPT came up for me:
I've been playing around in MV again, trying some things out. This request is inspired by SNES games like Chrono Trigger and FF6 when a character casts a spell, or uses a skill, the battle background darkens with what's like a 50% black transparent overlay or is just tinted darker in a similar way. The darkening fades in just prior to the spell animation, and fades back to default tinting when the spell animation is over. It only affects the background, not the sprites or any other graphical elements on the screen.
One idea for implementation would be that this effect could be applied to skills in the database that have the <isDarkened> tag. It's an idea anyway. I know PixiJS does a lot of graphical things, so maybe using that could help?
I HAVE tried using ChatGPT to help me out (don't judge me), as I'm not a programmer. There's been some mild success after hours of tweaking, but only in applying a darkly tinted effect to the background (is just there at the beginning of battle and persists).
If anyone could help me out or point me in the right direction, it would be much appreciated. Thanks!
For reference, here's a thing ChatGPT came up for me:
JavaScript:
Scene_Battle.prototype.createSpriteset = function() {
this._spriteset = new Spriteset_Battle();
this.addChild(this._spriteset);
// Create the darkened background filter
this._darkenedBackgroundFilter = new PIXI.filters.ColorMatrixFilter();
this._darkenedBackgroundFilter.matrix = [
0.5, 0, 0, 0, 0, // Red
0, 0.5, 0, 0, 0, // Green
0, 0, 0.5, 0, 0, // Blue
0, 0, 0, 1, 0 // Alpha
];
// Apply the filter to the battle background
this._spriteset._battleField.children[0].filters = [this._darkenedBackgroundFilter];
// Add a property to control fading
this._darkenedBackgroundFade = {
targetBrightness: 0.5,
currentBrightness: 0.5,
fadeSpeed: 0.02
};
};
// Add this function at the end of Scene_Battle
Scene_Battle.prototype.updateDarkenedBackground = function() {
if (this._darkenedBackgroundFilter.enabled) {
if (this._darkenedBackgroundFade.currentBrightness < this._darkenedBackgroundFade.targetBrightness) {
this._darkenedBackgroundFade.currentBrightness += this._darkenedBackgroundFade.fadeSpeed;
} else if (this._darkenedBackgroundFade.currentBrightness > this._darkenedBackgroundFade.targetBrightness) {
this._darkenedBackgroundFade.currentBrightness -= this._darkenedBackgroundFade.fadeSpeed;
}
this._darkenedBackgroundFilter.brightness(this._darkenedBackgroundFade.currentBrightness);
}
};
// Call this function at the end of updateMain in Scene_Battle
Scene_Battle.prototype.updateDarkenedBackground();
// Modify startAnimation in Sprite_Animation
Sprite_Animation.prototype.startAnimation = function() {
this._darkenedBackgroundFilter.enabled = true;
this.isPlaying = true;
};
// Modify update in Sprite_Animation
Sprite_Animation.prototype.update = function() {
Sprite.prototype.update.call(this);
if (this.isPlaying && !this.isAnimationPlaying()) {
this._darkenedBackgroundFilter.enabled = false;
this.isPlaying = false;
}
};