Hi! I have made a simple Confetti Effect script (first script, with the help of ChatGPT 😅) and after some struggling it works. I would like to share it with you. Maybe it can help someone...
Usage:
To activate script you use SCRIPT command on an event and paste this code:
SceneManager._scene.startConfettiEffect();
If you call the event multiple times... more confetti. Pretty simple.
The effect is auto-disables when you leave the map
You need to have images for the confetti on your /img/pictures/ folder. Their name should be confetti.png, confetti2.png, and confetti3.png. You can change this or add more images or whatever editing this line of the script:
var confettiImages = ['confetti', 'confetti2', 'confetti3'];
I used these three images, you can use them, or edit them or whatever you want. Same with the code. Use it, edit it, improve it, I dont really care.
Greetings, friends!
// ==Plugin==
// @name confetti
// @desc A plugin to add colorful confetti effect to the game.
// ==/Plugin==
(function() {
var confettiEnabled = false;
var confettiContainer = null;
var shouldStopConfetti = false; // New variable
var _Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
_Scene_Map_start.call(this);
if (confettiEnabled && !shouldStopConfetti) { // Check shouldStopConfetti
this.startConfettiEffect();
}
};
var _Scene_Map_terminate = Scene_Map.prototype.terminate;
Scene_Map.prototype.terminate = function() {
_Scene_Map_terminate.call(this);
shouldStopConfetti = true; // Set to true when scene terminates
this.stopConfettiEffect();
};
Scene_Map.prototype.startConfettiEffect = function() {
var confettiContainer = new Sprite();
confettiContainer.z = 10;
this.addChild(confettiContainer);
var confettiImages = ['confetti', 'confetti2', 'confetti3'];
var numConfetti = 100;
for (var i = 0; i < numConfetti; i++) {
var confettiImage = confettiImages[Math.floor(Math.random() * confettiImages.length)];
var confetti = new Sprite(ImageManager.loadPicture(confettiImage));
confetti.x = Math.random() * Graphics.width;
confetti.y = -Math.random() * 200;
confetti.anchor.x = 0.5;
confetti.anchor.y = 0.5;
confetti.rotationSpeed = Math.random() * 0.1 - 0.05;
confetti.fallSpeed = Math.random() * 2 + 2;
confetti.tilt = Math.random() * 30 - 15;
confetti.blendMode = PIXI.BLEND_MODES.ADD;
confettiContainer.addChild(confetti);
}
confettiContainer.update = function() {
for (var i = 0; i < this.children.length; i++) {
var confetti = this.children[i];
confetti.rotation += confetti.rotationSpeed;
confetti.y += confetti.fallSpeed;
confetti.x += Math.sin(confetti.rotation) * confetti.tilt;
if (confetti.y > Graphics.height) {
confetti.x = Math.random() * Graphics.width;
confetti.y = -10;
}
}
};
};
Scene_Map.prototype.stopConfettiEffect = function() {
if (confettiContainer) {
this.removeChild(confettiContainer);
confettiContainer = null;
}
};
})();
Usage:
To activate script you use SCRIPT command on an event and paste this code:
SceneManager._scene.startConfettiEffect();
If you call the event multiple times... more confetti. Pretty simple.
The effect is auto-disables when you leave the map
You need to have images for the confetti on your /img/pictures/ folder. Their name should be confetti.png, confetti2.png, and confetti3.png. You can change this or add more images or whatever editing this line of the script:
var confettiImages = ['confetti', 'confetti2', 'confetti3'];
I used these three images, you can use them, or edit them or whatever you want. Same with the code. Use it, edit it, improve it, I dont really care.
Greetings, friends!