How do I prevent the brief flash of black between loading pictures?

I have a picture that loads with every step the character takes (the game is a dungeon crawler done mostly with eventing). This picture is the "room" the player is in.

Everything works well except that the first time the player enters a "room" and the picture displays, there is a brief quarter-second of black as the old picture ("room") unloads and the new one is displayed.

However, when the character revisits the same room (i.e. a picture is loaded that was previously loaded), there is no pause and the picture displays immediately without the black transition.

Presumably this is due to loading the picture the first time (subsequent times it is still in memory?). If so, is there a way to avoid this?

I first tried calling a common event that loads *all* the pictures in succession before the game starts, but that doesn't seem to prevent the black "flash" between pics during normal gameplay. I also tried a "preloader" plugin called "YSP_Preloader" but it didn't seem to make any difference either. The only other preloader plugin I found was by SRD but requires a bunch of other plugins I don't really want to install just for this issue. I also found one by Galv, but that requires manually entering every single picture I'd want to preload by hand (I can't find a way to tell it to load a whole folder).

If anyone can give me any advice (either on why this happens if I'm wrong, or how to fix it), I'd really appreciate it!

It's not the end of the world if it can't be fixed, but really makes the game look less professional.

Side note: is there a way to add transitions (dissolve, etc.) between two pictures that replace each other?

EDIT: I tried Galv's (text editor for the win to copy all filenames!) and it *sort of* works; the black between images is much shorter but still there the first time an image loads. Revisiting the room has no black between images at all, so it's still a loading/memory problem it seems.
The reason you don't get the delay when re-entering a room is because the previous picture is still in memory. If you went to another room, saved and closed the game, when you reloaded and return to the first room, the delay will be there again.

If you determine that the loading time is around half a second, you could do a fadeout prior to each transfer, do the transfer, wait a little more than half a second (enough time for the picture to load), then fadein. The wait and fadein may need to be in an autorun event on the new map rather than after the transfer command, as sometimes commands following a transfer to another map do not get run - especially if there is a wait.

If you want to get really clever, instead of waiting a set number of frames, you could put a loop to wait 1 frame followed by a conditional branch with a script call to see if the loading has completed. I'm not sure what the command would be off the top of my head, but if you really want to try that, post back and I or someone else can look it up for you. I think a set number of frames would be easier and more consistent from the player's point of view.
and the reason why your common event loading every picture up front didn't work is because there is a limit to the RAM. Each browser has a function usually called "garbage collector" that checks the used RAM for currently unused resources and deletes them when the cache is full (or above a set percentage limit).
so your loaded pictures get deleted from RAM before you need them later.

There are plugins/scripts (called preloader) that can handle this better than a common event, but those have disadvantages in the regular RAM-use and may cause memory leaks, lag and crashes if used wrongly.

Basically depending on how your game is organized you can try to load a specific picture before entering a room/map that needs it, but that would require you to know where the player goes before he goes there.
Thank you VERY much for the information and advice. This is my first time doing this kind of "non-JRPG hack" thing with MV (last time was way back with 2000!) so I;m still working on best practices. I appreciate any help, even if this can't be resolved as I want it to be.

The reason you don't get the delay when re-entering a room is because the previous picture is still in memory. If you went to another room, saved and closed the game, when you reloaded and return to the first room, the delay will be there again.

If you determine that the loading time is around half a second, you could do a fadeout prior to each transfer, do the transfer, wait a little more than half a second (enough time for the picture to load), then fadein. The wait and fadein may need to be in an autorun event on the new map rather than after the transfer command, as sometimes commands following a transfer to another map do not get run - especially if there is a wait.

If you want to get really clever, instead of waiting a set number of frames, you could put a loop to wait 1 frame followed by a conditional branch with a script call to see if the loading has completed. I'm not sure what the command would be off the top of my head, but if you really want to try that, post back and I or someone else can look it up for you. I think a set number of frames would be easier and more consistent from the player's point of view.

My issue with using fades - unless I'm misunderstanding you (very possible!) - is that the "room" images are just the top 640x480 of the screen, the rest of the screen being other pictures that make up the game's GUI (stats, controls, etc.). Thus, I'd need to fade/dissolve between the top-left picture (in my case, image ID 20) *only* otherwise the whole GUI would disappear and reappear each room, looking worse than the room going black for a second. Is there a way to do what you suggest with just that image (i.e. dissolving between two pictures with the same ID)?

and the reason why your common event loading every picture up front didn't work is because there is a limit to the RAM. Each browser has a function usually called "garbage collector" that checks the used RAM for currently unused resources and deletes them when the cache is full (or above a set percentage limit).
so your loaded pictures get deleted from RAM before you need them later.

There are plugins/scripts (called preloader) that can handle this better than a common event, but those have disadvantages in the regular RAM-use and may cause memory leaks, lag and crashes if used wrongly.

Basically depending on how your game is organized you can try to load a specific picture before entering a room/map that needs it, but that would require you to know where the player goes before he goes there.

That sounds idea, but knowing where the player is going before they do is the problem, since I currently use event names for "rooms", as follows:

* Each room has it's own unique picture (640x480 png).
* Each tile on the map is a "room" with its own "player touch" event.
* The player moves in an available direction (N/S/E/W) via either the arrow keys or clicking onscreen movement controls (using Yanfly's picture event plugin).
* When the player moves to a new tile/room, an "on touch" event checks the event name (e.g. "Cave-A2"), sets that as a variable and then translates this to a show image script call that uses the variable to decide what picture to show.

This means I currently have no way to set the image before the player moves to that room.

Note: the player never sees the "map", just the GUI and room pictures overlaid on top.

Does that make sense or would it be more helpful to post a screenshot or some code snippets?
the "room" images are just the top 640x480 of the screen, the rest of the screen being other pictures that make up the game's GUI (stats, controls, etc.). Thus, I'd need to fade/dissolve between the top-left picture (in my case, image ID 20) *only*
Super easy then! Instead of fading the screen, use a "blackout" picture that can fade in and out over the area you want to hide.

Create an image that is exactly the area you want to fade (640x480) and paint it black. Save it in your Pictures folder.

At the start of the game, do a Show Picture to show this image in the top left corner (0, 0) and using (0, 0) as the anchor, at a 0 opacity. This will ensure it's loaded when you need it.

When you're ready to transfer, do a Move Picture and change the opacity to 255 over whatever duration you want. Then transfer, wait X frames, and another Move Picture to change the opacity to 0 over the required duration. Again, you might have to split this into two events - one that makes the picture opaque and does the transfer, and another autorun on the new map that waits until the "room" picture is loaded then makes the "blackout" picture transparent (and erases itself when done).

The trick is to use the highest picture slot available (by default I think that's 50) which will make it appear over all other pictures you are currently displaying.
You asked about fading one picture into another one too. You can't technically do that with only one picture though, you can use two picture IDs though.

If you start with Picture ID 1 in room one, and then when the player moves to room 2, use picture ID 2 instead.
Initially when you call to show the second picture, make it 0% opacity, so it'll be invisible, then call two move picture events over 15-20 frames to make picture 1 0% opacity, and picture 2 100% opacity. This will make the two pictures cross fade into each other. Wait another 20 frames or so, and then load picture 1 again at 100% opacity, only using the picture for room 2, and at 100% opacity, and then delete picture 2 entirely.
When the player moves to the next room, do the same thing again.

This will make the room pictures crossfade into each other over 1/4 of a second, which should mitigate the split second of blackness as it loads a new one. By moving the second picture into the first picture ID after, it prevents you from having to keep track of which picture ID is currently being used for the room picture too.

Edit:
Alternatively, if you don't like the crossfade look, you can do something almost the same without crossfading.
  • Enter room
  • Load picture 1, for current room
  • Move to next room.
  • Load picture 2, the picture for the current room, 100% opacity
  • Show picture 1, the picture for the room you just walked into
    • Because it has a lower ID than the NEW room 1 picture we loaded, it shows under the picture for room 1, so you won't see the blackness.
  • Wait for 15-20 frames for the image to load, then delete picture 2
That'll load the picture while hiding it, and then instantly show it when you delete temp picture ID 2, and also maintains that the picture being used is always ID 1, for ease of programming later.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-prevent-the-brief-flash-of-black-between-loading-pictures.142282/