• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] fade-in/out transition object defaulting to 0/0 in view

T

Tofu Heavy Industries

Guest
I have an object that acts as black fade-in fade-out transition thingie. Whenever I use it, if the room has a view, the view in the room will be snapped back to x0 y0. I don't know why this is happening. But will retain the correct size of the view itself.

The calling object is persistent in the room its in, with a depth of 1.

calling line
Code:
instance_create(view_xview[0],view_yview[0],obj_fader);
Object Properties: obj_fader
Sprite:
Solid: false
Visible: true
Depth: -9999
Persistent: true
Parent:
Children:
Mask:
No Physics Object


obj_fader: Create
Code:
AlphaLevel = 0;
fade = 1;
obj_fader: Draw
Code:
AlphaLevel = clamp(AlphaLevel + (fade * 0.05),0,1);

if (AlphaLevel == 1) {
    room_goto(global.room_going_to);
    fade = -1;
}
if ((AlphaLevel == 0) && (fade == -1)) {
    instance_destroy();
}
draw_set_colour(c_black);
draw_set_alpha(AlphaLevel);
draw_rectangle(view_xview[0],view_yview[0],view_xview[0] + view_wview[0],view_yview[0] + view_hview[0],0);
draw_set_alpha(1);
 
T

Tofu Heavy Industries

Guest
I added a draw gui event to the obj_fader and added that line - no text output.
I put that line in the regular draw event of obj_fader - no text output.

I even put it into a persistent control object with a draw event and that didnt work.

Additional info: the view[0] is following obj_main, which has no draw event itself, and creates an instance of obj_fader during its STEP event.
 

TheouAegis

Member
Put my line in the GUI event of obj_main. It MUST be in a GUI event.

The fact you never saw anything at all suggests maybe the text was misaligned. So change the x to view_wview/2 and change y to 64.

Do you have code anywhere that affects the view?
 
T

Tofu Heavy Industries

Guest
Active during the whole time is just :
obj_main - player character
obj_control - game control object

putting that code line in either of those objects (in the draw gui event) does nothing. Well, it will show the object name of what its in (in the view as it should be), but as soon as an instance of obj_fader is created, it goes blank.

Checking around for other view code - nothing else modifies it.
 

TheouAegis

Member
Wait, what? It shows the name of the following object and then shows nothing at all when obj_fader is created?! That's not right. Unless it's cuz you have the draw colour set to black so the text is just covered by the fader.

Is the game snapping to (0,0) of the first room or the next room? The view might be trying to go outside the room. Track the coordinates of obj_main before and after the transition.
 
T

Tofu Heavy Industries

Guest
I made sure to set the font color to white.
its snapping to the 0,0 of the room its currently in, not the room its going to.

thanks theou - the problem was i set the x/y for obj_main to 200,96 right after creating the fader object, so it would snap there.
I just moved the code to set obj_main x/y AFTER it enters the next room.


im still not sure why the line of code you provided never appeared.
 
Top