Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Turn current screen into background or other image?  (Read 2063 times)

0 Members and 1 Guest are viewing this topic.
Turn current screen into background or other ima...
« on: July 04, 2009, 01:50:46 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1626
A Gamemaker question

Why:
In my game I want to create a better pause option. Before I did pause by running through all relevant objects, saving there current state and then stopping them. I didn't have pro so it seemed one of few available options. The drawbacks are that it's not efficient, not failprove and a pain to keep up as more objects are added to the game. I just got the pro addition and I'm working on a better sollution. I just haven't been able to get the bit below to work.

The problem:
I want to create a screenshot of the current screen and save it to a background (or object).

The reason for this is that I want to place that screenshot at depth X covering the current screen so that I can still place menu's etc in front of it while being able to deactivate all objects behind. I anybody thinks there is a more efficient/easier way to do something like this than be sure to drop a hint XD

Any help will be appreciated.
Logged
Re: Turn current screen into background or other...
« Reply #1 on: July 04, 2009, 03:06:24 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1626
Never mind. I figured it out myself.

The pause script is now:
Quote
obj_Master_Control_Tile.Game_Mode = argument[0];
screen_save(temp_directory+'\tempscreen.bmp');
sprite_replace(842,temp_directory+'\tempscreen.bmp',1,false,false,false,false,0,0);
instance_deactivate_all(true);

// (Re)activate all the needed objects
instance_activate_object(parent_Control_Tile);
instance_create(view_xview[view_current], view_yview[view_current], obj_Screenshot);

The unpause script is now:
Quote
obj_Master_Control_Tile.Game_Mode = 0;
with (obj_Screenshot) {instance_destroy()};

// Reactive all instances
instance_activate_all();

Well that's the basis anyway. I left out the gamespecific / boring bits.
Logged

noseblunt3

Woodman is awesome
Re: Turn current screen into background or other...
« Reply #2 on: July 04, 2009, 04:09:36 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 132
You should check out this topic http://www.zfgc.com/forum/index.php?topic=1603.0
It explain how to do it with surface. Pretty useful.
Logged
Rome wasn't built in a day, but they didn't waste time by sitting around doing nothing either!
Re: Turn current screen into background or other...
« Reply #3 on: July 04, 2009, 05:35:14 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1626
Looks usefull. I don't get it (yet) since I've never before used surfaces, alpha's or draw events, but I'll be sure to take a closer look at it when I have some more time.
Logged
Re: Turn current screen into background or other...
« Reply #4 on: July 04, 2009, 06:47:32 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1626
I just can't let this one go just yet. It works but I still don't get half of it.

Here is the code the guy in the other topic suggested:
Quote
s = surface_create(view_wview,view_hview);
surface_set_target(s);
draw_clear_alpha(c_black,0);
screen_redraw();
draw_set_blend_mode_ext(bm_inv_dest_alpha,bm_one);
draw_set_color(c_black);
draw_rectangle(view_xview,view_yview,view_xview+view_wview,view_yview+view_hview,0);
draw_set_blend_mode(bm_normal);
surface_reset_target();
instance_deactivate_all(1);

Here is the code I am using, that seems (?) to work just as well:
Quote
surface_screenshot = surface_create(view_wview[current_view], view_hview[current_view]);
surface_set_target(surface_screenshot);
screen_redraw();
surface_reset_target();
instance_deactivate_all(true);

Both codes looks more efficient then my own concoction since they do not require saving to an external file, changing a sprite's image and they have the option to later empty the used layer. You create a surface, draw the current screen onto it and use it as a replacement image during the drawing event of an object. I get that part.

So what do the lines do between my shorten code and the code above it? What is there added value?
Logged

noseblunt3

Woodman is awesome
Re: Turn current screen into background or other...
« Reply #5 on: July 04, 2009, 10:28:25 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 132
Quote
So what do the lines do between my shorten code and the code above it? What is there added value?
They draw a semi-transparent black rectangle on the screen, to give an impression of darkness.
Logged
Rome wasn't built in a day, but they didn't waste time by sitting around doing nothing either!

DJvenom

super-sage
Re: Turn current screen into background or other...
« Reply #6 on: July 04, 2009, 10:32:58 pm »
  • Colbydude was here.
  • *
  • Reputation: +7/-0
  • Offline Offline
  • Gender: Female
  • Posts: 2898
background_create_from_screen(x,y,w,h,transparent,smooth,preload) ?? or did GM7 remove that functipon?
Logged
I do art
I ermmm... DID do art
I do art
Re: Turn current screen into background or other...
« Reply #7 on: July 05, 2009, 05:12:59 am »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1626
Okay, so that stuff is usefull for when you want to change the colors to empifice your pause mode.

DJVenom: You can still use it. It saves the screenshot into a background but the surface bit seems more practical now since backgrounds don't have variable depth. The background will either get behind my tiles or infront of my menu's.

Still it's good to know such functions exist. Thanks.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.116 seconds with 53 queries.

anything