• 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!

about room transition effect

V

VaygrEmpire

Guest
How do I give room transition effect? I googled a bit but found out that transition_kind is obsolete. What I want is to slide down a new room from top to bottom when room is changed. (I know about room_goto(). what I want to know is transition effect)

If it is gml, sample code would be appreciated.

Thanks for any help in advance!
 

Yal

🐧 *penguin noises*
GMC Elder
One idea is to take a surface screenshot of the room (check out view_surface and the manual page about how to create, draw and delete surfaces) to a surface stored in a global variable, change rooms, and in every room, have a 'room start' object that draws the appropriate effect using the surface (e.g. drawing with slowly fading alpha to blend the rooms, move the surface upwards to scroll the new room into place, and so on).
 

Genetix

Member
I agree, in simple terms capture the screen before leaving a room, as you enter the next room draw the captured screen and have it moving in the direction of the transition - it is a decent theory.
 

Yal

🐧 *penguin noises*
GMC Elder
Oh, and for transitions in general, a little tip... when you change rooms, have the player object destroy itself and create a 'transit TO another room' object. Instead of placing the player directly in rooms, you place a player spawner, that first spawns a 'transit FROM another room' object and then waits until it's gone, and THEN it spawns the player. This way you can take your time fading out and have all sorts of effects, and there's no risk the player manages to die before they even got to see the level. I mostly just fade to black or things like this, but you can use any sort of effect with these objects, really.

You might also want to look into shaders... applying them to the whole screen can let you do some cool effects as well relatively easy, like draining the pixels of lumiosity for a fade, or change their coordinates for an 'old TV turn off' effect.
 
J

jackhigh24

Guest
@Fel666 that's a bad example, not sure why yoyo have put it on there site, it does all the things you are not meant to do, although it does work.
 

GMWolf

aka fel666
@Fel666 that's a bad example, not sure why yoyo have put it on there site, it does all the things you are not meant to do, although it does work.
I didn't see anything horribly bad with the example... There where a couple things to keep in mind when developing the rest of the game (like not updating game whilst transition is still going) but aside from that..
Regardless, its a great place to start.
 
J

jackhigh24

Guest
@Fel666 ye it not bad but creating and copying surfaces in create and step events is not recommended, but hay if it works it works right.

EDIT
actually i must apologize, no sleep for a few days and im getting all frosty ;) sorry about that.
 
J

jackhigh24

Guest
@Fel666 ye just having a grumpy day, and do feel i did need to say that as i thought i was being a little snarky at the end there, it is because i thought we were getting away from using bad practices with new forum, i remember @Mike saying that was one of the bad things about the old place coursing confusion for anyone learning, and as iv been struggling with surfaces due to what i now think is bugs in game maker, then trying to double check that is hard when we get stuff that shows to do it the way the manual says not to.
 

GMWolf

aka fel666
@Fel666 ye just having a grumpy day, and do feel i did need to say that as i thought i was being a little snarky at the end there, it is because i thought we were getting away from using bad practices with new forum, i remember @Mike saying that was one of the bad things about the old place coursing confusion for anyone learning, and as iv been struggling with surfaces due to what i now think is bugs in game maker, then trying to double check that is hard when we get stuff that shows to do it the way the manual says not to.
Im a little confused: does the manual say surfaces should not be copied outside the draw event? i havnt found that when looking for it.
 
J

jackhigh24

Guest
well not in those exact words, but it does say you should not do anything with surfaces outside the draw event, also had that confirmed by a member of staff, so things are getting confusing making it really hard to pinpoint issues.
 

Mike

nobody important
GMC Elder
You shouldn't really do any rendering stuff outside of the draw events, as the drawing context may not be setup correctly - especially on the 1st few frames of the game.

Ideally, in the create event set a mysurface=-1; Then in the draw event test to see if "mysurface" exists, and if not create it.
In terms of transitions, use the post draw event (as the game already exists on the application_surface). Then when you swap room, just draw the transition surface over the top of everything in the Post Draw event and do what you want with it.

Transitions are pretty simple, especially once you have a simple framework in place......
 

ShaunJS

Just Another Dev
GMC Elder
Ideally, in the create event set a mysurface=-1; Then in the draw event test to see if "mysurface" exists, and if not create it.
Hah, good to know the way I intuitively did it was ideal for once!
 

GMWolf

aka fel666
You shouldn't really do any rendering stuff outside of the draw events, as the drawing context may not be setup correctly - especially on the 1st few frames of the game.

Ideally, in the create event set a mysurface=-1; Then in the draw event test to see if "mysurface" exists, and if not create it.
In terms of transitions, use the post draw event (as the game already exists on the application_surface). Then when you swap room, just draw the transition surface over the top of everything in the Post Draw event and do what you want with it.

Transitions are pretty simple, especially once you have a simple framework in place......
but what about copying surfaces. thats isnt really rendering, or does GM actually draw one surface onto the other rather than copying data around?
 
J

jackhigh24

Guest
Hah, good to know the way I intuitively did it was ideal for once!
yes indeed but thats not the way the techblog above is promoting how to do it, really techblogs should be doing it the right way in my opinion as its just teaching you how to do it the wrong way, yes it works, but when we are told one way then another it makes learning very hard.
 
V

VaygrEmpire

Guest
what causes sliding effect to happen? I downloaded one of the free assets on the marketplaces about transition and below is the code:

Code:
Script - original code:
///room_goto_transition(room,transition,[steps],[col],[jam]);

///change room based on time - original code
if room == room_test1 {
room_goto_transition(room_test2,next_transition,10+irandom(80),choose(c_lime,c_yellow,c_white,c_black,c_gray),true);
}

Script - modified code:
///transition_effect(room,transition,[steps]);

///Change room - modified code
if room == rm_mission_cloud {
 transition_effect(rm_mission_city,next_transition,30);
} 

//Slide down - original code
if kind == transition.slide_down {
if room != next_room {
  room_goto(next_room);
}
draw_surface_stretched_ext(surface_from,0,current_step/length*__gui_height,__gui_width,__gui_height,c_white,1);
}

///Slide down effect - modified code
if kind == transition.slide_down {
if room != next_room {
  room_goto(next_room);
}
draw_surface_stretched(surface_from,0,length*__gui_height,__gui_width,__gui_height);
}
the only difference between the original code and modified one is whether it has color and jam (last 2) or not - and I made sure to take them out from script as well.

Right now, the room does change, but it still doesn't have any effect.
original source:
https://marketplace.yoyogames.com/assets/2291/transition-system

Sure, I had to modify based on my game and background does change according to timed event, it just doesn't have any effect.
 
Last edited by a moderator:

Mike

nobody important
GMC Elder
but what about copying surfaces. thats isnt really rendering, or does GM actually draw one surface onto the other rather than copying data around?
Copying is still rendering these days. It sets the surface, and then draws 2 triangles then sets it back again.
 
  • Like
Reactions: Yal
Top