here's a simple function as example:
void load_level_fade_black(STRING* _levelname)
{
PANEL* TempPan = pan_create("alpha = 0; flags = SHOW | TRANSLUCENT", 1000); // Create a new temp-panel
BMAP* BmapBlack = bmap_createblack(8, 8, 24); // create an 8x8 black texture
TempPan.bmap = BmapBlack;
TempPan.size_x = screen_size.x; // set x and y size of the panel to the game-resolution
TempPan.size_y = screen_size.y;
var p = 0; // percent (1 - 100)
var Speed = 1.5; // fade-speed per frame
while(p < 100) // fade in
{
p += Speed;
TempPan.alpha = p;
wait(1);
}
TempPan.alpha = 100;
level_load(_levelname); // screen is black, load the level now
p = 100;
while(p > 0) // now the same just backwards
{
p -= Speed;
TempPan.alpha = p;
wait(1);
}
TempPan.alpha = 0;
ptr_remove(TempPan);
ptr_remove(BmapBlack);
}
if you usually use level_load("level.wmb"); you can now use:
load_level_fade_black("level.wmb");
instead - which will do exactly the same, just with fading the screen black before loading the level.
I simply create a panel and assign a black texture to it with the size 8x8.
(2^x textures wich are greater or equal 8x8 px will be repeated seamlessly if the panels' size_x and _y are bigger)
Then I set size_x and _y to the applications' resolution so the complete screen gets covered.
After that I use a simple linear fade-in to show the panel, load the level and then blend it out again.