EDIT: RIP, got beat to the punchline xD
@Lysho , I'm trying to create a clip mask that prevents selected sprites from being seen outside the rectange, like how you can only view a certain portion of a webpage at a time within a GUI window in an operating system.
So you want to only see sprites inside that rectangle? So you want all other sprites outside of the rectangle to just be invisible or clipped from view, yes? I'm a little confused because you say you want only selected sprites from being seen outside the rectangle, but then when you say 'viewing a certain portion of a webpage', you also suggest as long as its outside of the rectangle, it should be clipped.
I'll assume you just want things inside the rectangle to be visible, and everything else to be clipped out of the picture. I spent some time tinkering with this example system but it works perfectly. It may not be exactly what you're looking for, but you could try dissecting it and then repurposing it how you like. Here's a link of a gif showing what I scrapped together:
http://gph.is/2nmoTc6
There are two objects involved in this (not counting the blue thing lol): an object that makes the black screen, and an object that "punches a hole" in the black screen so you can see through it like a window.
create an object called obj_covered with a depth more negative than every object you want to cover(so something like -1000)
create event
Code:
surf = -1; //initialize the surface variable
draw event
Code:
if !surface_exists(surf){ //surfaces are 'volatile', they can be destroyed randomly, so always check!
surf = surface_create(room_width,room_height); //size it to the room size to cover everything
surface_set_target(surf); //begin drawing to this surface
draw_clear(c_black); //make it totally black to cover everything, hence why -depth to be on top
surface_reset_target(); //stop drawing to this surface
}else{
draw_surface(surf, 0, 0); //if the surface exists, draw the surface to the game
}
Now create a sprite of any size (you can always scale it to a certain size in the create event of the window object. I called it obj_revealed
Step event (this is so the window moves following the mouse. you can make it move however you like)
Code:
x = mouse_x;
y = mouse_y;
Draw event (where the magic happens)
Code:
if instance_number(obj_covered) > 0 then{ //always check if it exists to avoid crashes
if surface_exists(obj_covered.surf) then{ //again, check if the surface exists to avoid crash
surface_set_target(obj_covered.surf); //start drawing to the surface
draw_clear(c_black); //make it black again (or else you always erase and it never recovers itself)
draw_set_blend_mode(bm_subtract); //time to erase or punch a hole!
draw_self(); //whatever the sprite it, punch that out
draw_set_blend_mode(bm_normal); //revert to normal!
surface_reset_target(); //stop drawing to this surface
}
} else{
draw_self();
}
Is this what you were looking for?