My last post was about some nice art as an aside from fixing some bugs. This time . . . not so much.
I was hoping to have the devblog part of the website up before I did devlog posts. But I haven’t gotten around to that (busy coding the game ye’ know.)
I found a really interesting issue when working with Game Maker. So you will have to have some familiar understanding of the engine (or at just read the docs.)
In GM8 there was a function background_create_from_screen. This function essentially acted as a screen shot and and and gave us a workable image as a placeholder while we called instance_deactivate_all() which will pause the game, but it will also stop all the objects from drawing themselves. We use the captured image to show the game while there is really nothing that the game is drawing.
The problem. Well background_create_from_screen isn’t in Game Maker: Studio (no idea why).
My initial solution to this problem was to create a surface and draw all the stuff on the screen to the surface, and save that image. Unfortunately this image wasn’t a 1:1 with how the game looked. Some pixels were drawn differently and so on. There are a number of ways that it could have been made to work, but I wanted a solution that really worked.
There is another function in GM called screen_save (it’s the one I used to get that image up there) which basically does a screencap of what the game is showing and saves it as a .png file. So I just load that in with background_add. Sound simple.
Did I mention that background_add doesn’t actually work? Ye it doesn’t. And after some minor deskfacing I came up with a work around. I can load the image with sprite_add! So I take the image (now a sprite) and draw it to a surface, and I then save this surface as a background, and there I have my background_create_from_screen back again!
And for anyone interest here is the code I am using to do this.
screen_save( "bg.png"); _spr = sprite_add( "bg.png", 0, false, false, 0, 0); _sur = surface_create( view_wview, view_hview); surface_set_target( _sur); texture_set_interpolation( false); draw_clear_alpha( 0, 0); draw_set_alpha(1); draw_sprite( _spr, 0, 0, 0); _bg = background_create_from_surface( _sur, 0, 0, view_wview, view_hview, false, false); surface_reset_target(); sprite_delete( _spr); surface_free( _sur); return _bg;