Hello there!
Before I start, here is what I am using to test this at the moment:
OS: Windows 10 PRO 1909 (18363.836)
Game Maker Studio: 2.2.5.481
Runtime: 2.2.5.378
And I think that's all that may be relevant.
So, after using the code below to change the background image's alpha of a room called "room_gameStart" (the first room to appear in game after pressing F5) from 1 (by default) to 0 applying an alpha reduction of 0.01 per step, and game is running at 60 steps per second (60 fps), so the background alpha change should take about a 1.67 seconds to go from totally visible (alpha = 1) to totally invisible (alpha = 0), but even if the alpha is being reduced every step, the background image doesn't do the "fade" effect it should and stay as visible as the beginning (like alpha = 1 ).
I have a debug message show every step with the current alpha of the background and shows that each step is being reduced successfully by 0.01, so the script works as intended but the image doesn't change.
I have an object called "obj_gameStart_to_titleScreen" which has two events:
- A CREATE event with this code:
- A STEP event with this code:
This object is placed in the center of the room "room_gameStart" (the only room I have for now), and the background layer of the room is named "Background", and it indeed has an sprite associated.
And thats all I think I can say. If you have any doubts, please, let me know, thank you!
Before I start, here is what I am using to test this at the moment:
OS: Windows 10 PRO 1909 (18363.836)
Game Maker Studio: 2.2.5.481
Runtime: 2.2.5.378
And I think that's all that may be relevant.
So, after using the code below to change the background image's alpha of a room called "room_gameStart" (the first room to appear in game after pressing F5) from 1 (by default) to 0 applying an alpha reduction of 0.01 per step, and game is running at 60 steps per second (60 fps), so the background alpha change should take about a 1.67 seconds to go from totally visible (alpha = 1) to totally invisible (alpha = 0), but even if the alpha is being reduced every step, the background image doesn't do the "fade" effect it should and stay as visible as the beginning (like alpha = 1 ).
I have a debug message show every step with the current alpha of the background and shows that each step is being reduced successfully by 0.01, so the script works as intended but the image doesn't change.
I have an object called "obj_gameStart_to_titleScreen" which has two events:
- A CREATE event with this code:
GML:
/// @description
fadeSpeed = 0;
GML:
if ( keyboard_check( vk_enter ) && fadeSpeed == 0 ) {
fadeSpeed = 0.01;
}
var layerId = layer_get_id("Background");
var backgroundId = layer_background_get_id(layerId);
var bgCurrentAlpha = layer_background_get_alpha(backgroundId);
if ( bgCurrentAlpha > 0 ) {
layer_background_alpha(backgroundId, bgCurrentAlpha - fadeSpeed);
}
show_debug_message(bgCurrentAlpha);
And thats all I think I can say. If you have any doubts, please, let me know, thank you!