![]()
Spr_roomtl = sprite_create_from_surface(application_surface, 0, 0, halfwidth, halfheight, false, false, 0, 0) Var halfwidth = surface_get_width(application_surface)/2 Var halfheight = surface_get_height(application_surface)/2 *shrugs* I don’t know why, it just works. This happens because we would normally need to display the new room for one frame so we could take an image of it, however recording the application_surface in the step event allows us to record what the room should look like and then overwrite this by drawing in the draw_gui event. The reason we want to flash up an image of the old room for one frame is because if we didn’t there would be a flicker when changing room. ![]() GAMEMAKER STUDIO 2 ROOM SPEED CODEWe use EaseOutQuad() to create a number between 0 and room_width that gets bigger the more frames that have passed, we then draw the two surfaces next to each other and offset them by this number to make it look like they are both sliding simultaneously.Īll of that code is pretty intuitive apart from that little chunk at the end. / I do this to hide the flicker where the next room pops up for 1 frame Var slideamount = EaseOutQuad(currentframe,0,room_width,maxframes)ĭraw_surface(sur_newroom,room_width-slideamount,0) convert the number of frames that have passed into a number between 0 and the room width ![]() Also you will have to remember not to move anything or start any animations on the next room until the transition has finished. Side note: Depending on your game you might want to use maxframes=room_speed*1.5 this would allow you to detach the length of the transition from the room speed and use a more absolute timing system. Together surface_create(), surface_copy() and application_surface basically take a screenshot of the game. The clever bit here is it duplicates application_surface which already contains an image of how the screen currently looks. Surface_copy() – This is used to duplicate a surface. Surface_create() – We use surface_create() to make a variable to store the surface. Persistent – This tells GameMaker that when we change the room we do not want this object to be destroyed. If you want to make any of these transitions last longer just make maxframes a larger number. We have recorded what the old room looks like so we can instantly go to the next room.Ĭurrentframe and maxframes – Used to record how long the transition lasts and how far through it we are. Surface_copy(sur_oldroom,0,0,application_surface) Sur_oldroom = surface_create(room_width,room_height) copy the old room so we can display it on the second room Persistent = true // when changing room keep this object alive We will do this with a sliding transition: GAMEMAKER STUDIO 2 ROOM SPEED HOW TOIn this article I will show you how to capture images of the current state of the screen and the basic method we will be using to trigger the transition and keep track of how far along the transition is. If you haven’t used surfaces before they are basically an empty canvas you can draw onto in the same way you draw any sprite onto the screen and anything you draw there is saved, these surfaces can then themselves be drawn onto the screen with everything you have added onto them. You can even use it to have a preview of how the other two transitions will work. GAMEMAKER STUDIO 2 ROOM SPEED FULLThis seems like a good place to say that I will be providing a GameMaker project file so you can see it working in full if you download that and you can grab any code you need or make changes and have a tinker. ![]() However this is just an illusion and is actually just many images that have been put together to look like this. Not only does that final transition look like you can see two rooms at the same time, but the second room looks like it has been broken up and brought on in chunks and put back together. Let’s look at the three transitions we are going to make : Now I’m sure you are already thinking “there are loads of guides for doing screen transition what are so special about these ones?” Well these screen transitions look like you can see two rooms at the same time. ![]() In this article we will learn how to do the first transition and there will be a follow up article showing you how to make the other two transitions. We will be learning how to do 3 room transitions starting off easy and each one just getting a tiny bit more complex. For the last few months I have been obsessing over using surfaces and how they can be used to do masking, lighting, outlines, shadows, and countless other powerful graphical features. So in this post I’m going to showcase surfaces in GameMaker as it is one of the many features I feel doesn’t get the attention it should. When Shaun Spalding approached me to write a guest blog article I knew I wanted to do something at an intermediate level to help those who have got the basics down and understand how GML works. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |