MV Trying to make images for transitions

Hello, I'm here again being an absolute noob x') My JS knowledge is basic and my plugin making experience is also that, so please be patient.

I am trying to make transitions in game (when starting a new game, when loading, when going to title, when entering battle and leaving battle... basically scene transitions) work with images. In my specific case I have 3 images, one that covers the whole screen with dots, one with bigger dots, and a third one that is just black.

This works fine in a common event for, say, map transfers.
>Show image #1 transition1.png
>Wait X frames
>Erase image #1
>Show image #1 transition2.png...

I know the battle intro is a different thing, which is why I use a plugin to replace it with a common event (SRD_CEBattleIntro). However, by default, when the battle actually starts, there is a fadeout, and when it ends there is another fadein-fadeout to go to the map scene. I want to modify those very fadeins-fadeouts.

But well, by default it obviously doesn't use a multiple-image approach (there is no need for it to do so). I also don't truly understand how it 100% works. This is the function, so you have it at hand:

JavaScript:
Scene_Base.prototype.startFadeOut = function(duration, white) {
    this.createFadeSprite(white);
    this._fadeSign = -1;
    this._fadeDuration = duration || 30;
    this._fadeSprite.opacity = 0;
};

(And a similar one for FadeIn)

Anyway. Anytime this is used, duration is set as fadeSpeed(), which returns 24 by default. I made it 1 so the transitions were instant, and that works, again, up to a certain point. All my map transfers can use evented show image commands, but I can't do it with transitions between scenes. Could someone guide me a little?

I know how to load images with ImageManager.reservePicture(), as I've managed to draw busts to my menus with a custom function (that uses this.contents.blt()). But that was a static image in a menu. I have no idea how to show more than one, in sucession, after waiting frames, and make it an animation.

I can also figure how to set up plugin parameters that reserve the images that will be used, so other than that, can someone think of a way of showing images in sucession with frame waits in between?

Sorry if it's not that simple to implement, as again, I'm not great at code. But I figured I could ask before giving up and using a plan B. Thank you!
Sadly I can't help you with coding, but there's a plugin that might just do what you need here:
Sadly I can't help you with coding, but there's a plugin that might just do what you need here:
Thank you for the suggestion! But I don't want to use any paid plugin for my project x)
GradientWipe is a free one for maptransfers, cant say for load.

however, removing image 1 and show image 1 is a bad practice.

show image 1
wait x frames
show image 1 (different)

is far better as it will overwrite image id 1, so no reason to erase it.
GradientWipe is a free one for maptransfers, cant say for load.

however, removing image 1 and show image 1 is a bad practice.

show image 1
wait x frames
show image 1 (different)

is far better as it will overwrite image id 1, so no reason to erase it.
Ah, didn't know it would overwrite. I will be sure to use it like that, thank you.

Map transfers are fine, by the way, since you can just disable them in the event command and simply use images on top of it. It's the load (and all other) fadein-fadeouts that are a problem for me.

Edit: I will try this plugin later and see if it does what I want. I did see it before but I never tried it, I think it was when I was looking into battle intros. And if it doesn't work exactly how I want, I could at least look at the code...
I would also recommend using an existing plugin. @ShadowDragon's recommendation, Tsukimi's GradientWipe, looks great! 😂
Spoiler: technical navel gazing
All my map transfers can use evented show image commands, but I can't do it with transitions between scenes.
Each scene has its own behaviour for this stuff: check the various scenes' start and stop methods (rpg_scenes.js). The battle scene always fades in/out, but fade out speed is based on the next scene; the map scene has various conditions for both fade in and out; etc.

The fade sign & duration are values used in the scene's updateFade method. In case it's relevant: the map scene's flash & zoom battle entry effect is updated each frame by the updateEncounterEffect method, which includes a fadeout call.

I know how to load images with ImageManager.reservePicture(), as I've managed to draw busts to my menus with a custom function (that uses this.contents.blt()).
You've used the bitmap's "blit", a.k.a. "block image transfer", method to paint one texture (from file) onto another (the window's main content area). A Bitmap is not a display object: it's an abstract container for a texture, designed for use with a Sprite.

Instead you could create a Sprite object for the fade transition (much the same as the existing fade sprite) then periodically update its bitmap property with the next frame of your animation.
JavaScript:
// Define and add new display sprite as a child of `this`.
this.addChild(this._transitionSprite = new Sprite());
// Assign a new bitmap to that sprite.
this._transitionSprite.bitmap = ImageManager.reservePicture("transition1");
The updates could be performed by overriding a relevant method from the core scripts. One of the update methods I mentioned in the first part of this post may be a good candidate.

Also, stuff like transitions would typically be stored in img/system. Doesn't really make much difference, though, given MV's reservation system.

is far better as it will overwrite image id 1, so no reason to erase it.
It's not that big a deal: the sprite won't update between the Erase and Show commands. But yes, Erase Picture immediately followed by Show Picture on the same picture ID is redundant.
I would also recommend using an existing plugin. @ShadowDragon's recommendation, Tsukimi's GradientWipe, looks great! 😂
Spoiler: technical navel gazing
Each scene has its own behaviour for this stuff: check the various scenes' start and stop methods (rpg_scenes.js). The battle scene always fades in/out, but fade out speed is based on the next scene; the map scene has various conditions for both fade in and out; etc.

The fade sign & duration are values used in the scene's updateFade method. In case it's relevant: the map scene's flash & zoom battle entry effect is updated each frame by the updateEncounterEffect method, which includes a fadeout call.


You've used the bitmap's "blit", a.k.a. "block image transfer", method to paint one texture (from file) onto another (the window's main content area). A Bitmap is not a display object: it's an abstract container for a texture, designed for use with a Sprite.

Instead you could create a Sprite object for the fade transition (much the same as the existing fade sprite) then periodically update its bitmap property with the next frame of your animation.
JavaScript:
// Define and add new display sprite as a child of `this`.
this.addChild(this._transitionSprite = new Sprite());
// Assign a new bitmap to that sprite.
this._transitionSprite.bitmap = ImageManager.reservePicture("transition1");
The updates could be performed by overriding a relevant method from the core scripts. One of the update methods I mentioned in the first part of this post may be a good candidate.

Also, stuff like transitions would typically be stored in img/system. Doesn't really make much difference, though, given MV's reservation system.


It's not that big a deal: the sprite won't update between the Erase and Show commands. But yes, Erase Picture immediately followed by Show Picture on the same picture ID is redundant.
Unfortunately, I can't make GradientWipe work... As much as I read the description, I can't figure how to add more than one image per transition, and even if I try one of my images, it only loads a black screen with no transition.

I understand that updateFade lowers or raises the opacity, but I have no idea what the "fade sign" is @_@ Like... + or -? Or what else?

I think I understand what you said about creating a sprite and update its property with the next frame... but I have no clue how to actually write this x') I'm really sorry. I copied your snippet too but I obviously don't know what to do from there, or where to place it (I put it inside Scene_Base.prototype.createFadeSprite, which obviously doesn't work, because I can see the normal fade)

Also, my logic of using the pictures folder is that I plan on using different fades (in events, so no need to hardcode them) using the same images but with a different color, and Show Image command uses the pictures folder. You are right this would make more sense in system, but it doesn't make a huge difference.

Thank you very much for your response, even if I don't understand much x')
Gradient wipe uses a special layer from black to transparent and follow
it's path (as this example) as there are many different kind, you can make
your own and it will work.

I don't know how to add more image as it uses 1 image.
you can however uses many different kinds or use a random variable
to uses one at random from the image you have follow the same structure.
Ok, I have an update...! Thanks to caethryril's pointers I managed to figure it out x') (kind of) It is now very hardcoded and very not flexible... but I can work on that another day, and see if I can make it use parameters a little more dynamically.

Spoiler: Explanation of my silly code
Because this is how I set up the timing in my common events, I changed fadeSpeed() to 21 (7 + 7 + 7), and modified slowFadeSpeed() so it was the same as fadeSpeed. (It is inconvenient for me to have different fade speeds, unless I want to assign more pictures to that).

Then I changed createFadeSprite() to this:
JavaScript:
Scene_Base.prototype.createFadeSprite = function() {
    this.spriteTrans1 = new Sprite();
    this.spriteTrans1.bitmap = ImageManager.reservePicture("tranneg1");
    this.addChild(this.spriteTrans1);
    this.spriteTrans2 = new Sprite();
    this.spriteTrans2.bitmap = ImageManager.reservePicture("tranneg2");
    this.addChild(this.spriteTrans2)
    this.spriteTrans3 = new Sprite();
    this.spriteTrans3.bitmap = ImageManager.reservePicture("tranneg3");
    this.addChild(this.spriteTrans3)
};

Which is very redundant and stupid x') But that's what I have to work on, lol. It creates 3 sprites and adds them to the scene.

Then, in startFadeIn() and startFadeOut() I deleted the this._fadeSprite.opacity = 0; since it was already unused. I added my this.spriteTrans1 to 3 accordingly (set to 0 opacity), and the timing was precisely in updateFade():
JavaScript:
Scene_Base.prototype.updateFade = function() {
    if (this._fadeDuration > 0) {
        if (this._fadeSign > 0) {
            //esto es fadein (venir de negro)
            if(this._fadeDuration >14){
                this.spriteTrans3.opacity = 255;
            }
            if(this._fadeDuration <= 14 && this._fadeDuration > 7){
                this.spriteTrans3.opacity = 0;
                this.spriteTrans2.opacity = 255;
            }
            if(this._fadeDuration <= 7){
                this.spriteTrans2.opacity = 0;
                this.spriteTrans1.opacity = 255;
            }
           
        } //esto de abajo es el fadeout (irse a negro)
        else {
            if(this._fadeDuration > 14){
                this.spriteTrans1.opacity = 255;
            }
            if(this._fadeDuration <= 14 && this._fadeDuration >7){
                this.spriteTrans1.opacity = 0;
                this.spriteTrans2.opacity = 255;
            }
            if(this._fadeDuration <= 7){
                this.spriteTrans2.opacity = 0;
                this.spriteTrans3.opacity = 255;
            }

        }
       
        this._fadeDuration--;
    }
    if(this._fadeDuration <= 0 && this.spriteTrans1){
        this.spriteTrans1.opacity = 0;
    }
};

Which again, is very stupid. Because it only works properly if fadeSpeed is 21.
I also had to additionally set this.spriteTrans1.opacity to 0 when the transition is done, or else it would still be visible in the screen. Since the opacity doesn't change gradually like in the default functions, I guess I have to do that...

Anyway, uhhh, this works how I want to! Not sure if I should leave this thread open a little longer in case you feel like making suggestions... or a mod should just close it now. I plan on working more on this, but if further modifications don't work, I'll at least use this way, because well. It works, lol. Even if silly.

So, in summary, thank you caethryril! And everyone else too even if your solutions weren't the best for me, I appreciate the options x)
As you can see in the startFadeIn, startFadeOut, and updateFade methods (rpg_scenes.js), fade sign is simply +1 (fade in) or -1 (fade out).

You've used 3 separate sprites. That'll work, though it's a bit unnecessary. As I mentioned, you could just replace the bitmap on key frames instead of doing that "opacity swap" stuff.

(Note: setting a sprite's visible property to false makes the renderer skip it. That's a more typical way of "hiding" it than setting opacity to 0.)

The timing could be handled relatively by storing the total duration (and frame count) when the transition starts. That gives you enough information to calculate the key frames.

Also, I hope that code is in a separate .js file loaded as a plugin through the Plugin Manager. You implied you were going to write a plugin, and my suggestions were aimed at that. Editing the core scripts directly makes it considerably harder to track, port, and debug those edits...not to mention any resulting plugin conflicts!


Like @ShadowDragon says, to use GradientWipe you'd just need to merge your 3 single-colour images into a single, 3-shade greyscale image, e.g. black, 50% grey, white. It will then transition the active scene based on this image, from fully visible (white) to fully faded (black) or vice versa; examples are shown at 0:50+ in the video on the plugin's page. If you make the borders between shades sharp, rather than blurred, then the transition should progress in retro-style steps rather than smoothly.

Not every kind of transition can be expressed as a gradient/luma wipe, but it sounds perfect for a classic retro "growing dots" effect that I imagine from your description.
As you can see in the startFadeIn, startFadeOut, and updateFade methods (rpg_scenes.js), fade sign is simply +1 (fade in) or -1 (fade out).

You've used 3 separate sprites. That'll work, though it's a bit unnecessary. As I mentioned, you could just replace the bitmap on key frames instead of doing that "opacity swap" stuff.
I didn't think about that :0 Thank you! I modified it so it now does that.

(Note: setting a sprite's visible property to false makes the renderer skip it. That's a more typical way of "hiding" it than setting opacity to 0.)

The timing could be handled relatively by storing the total duration (and frame count) when the transition starts. That gives you enough information to calculate the key frames.

Also, I hope that code is in a separate .js file loaded as a plugin through the Plugin Manager. You implied you were going to write a plugin, and my suggestions were aimed at that. Editing the core scripts directly makes it considerably harder to track, port, and debug those edits...not to mention any resulting plugin conflicts!
Thank you for this suggestion as well, I changed it so it uses .visible instead of .opacity.

Don't worry! It's a proper plugin 🙂 And I managed to make it flexible now (with external help)! You now can set what each image is supposed to last in frames, and the number of images, and it does all the math by itself. It also automatically takes all images called trans0.png, trans1.png... in that order. I think it's usable for other people now hehe. I will make sure to share my plugin (for free) when my game is finished 😀


Like @ShadowDragon says, to use GradientWipe you'd just need to merge your 3 single-colour images into a single, 3-shade greyscale image, e.g. black, 50% grey, white. It will then transition the active scene based on this image, from fully visible (white) to fully faded (black) or vice versa; examples are shown at 0:50+ in the video on the plugin's page. If you make the borders between shades sharp, rather than blurred, then the transition should progress in retro-style steps rather than smoothly.

Not every kind of transition can be expressed as a gradient/luma wipe, but it sounds perfect for a classic retro "growing dots" effect that I imagine from your description.

I also appreciate this, but now that my plugin works I don't think I need anything else haha. It at least makes it simpler for me, I think...
This thread is closed due to being reported as solved. If you need it reopened, report the thread to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-images-for-transitions.173419/