What's wrong with my screenshot code?

B

Brleksak

Guest
Hi, I use this code to take a screenshot of where the mouse is placed (50x50px) and then I want that
screenshot to be the sprite of a certain object

_________________

Global left released:

var file;
file = screen_save_part(working_directory + "\Screens\Screen_"+string(num)+".png",mouse_x-25,mouse_y-25,50,50);
if file != ""
{
sk=sprite_add("Screen_"+string(num),1,false,false,25,25);
sprite_index=sk;
num+=1;
}

________________

Unfortunately its not working 100%, the screenshot is taken but the object does not recieve or update itself with the sprite? Also.. if I press several times it starts to act weirdly....

Thank you for helping
 

Tsa05

Member
Well, at a glance, you save this:
"\Screens\Screen_"+string(num)+".png"
and add this:
"Screen_"+string(num)
 
B

Brleksak

Guest
I added the .png.. it still doesn't work.. I checked the working directory,, it actually creates the screenshot and names it Screen_1.

But it still doesnt work :/,, the object just goes blank.

var file;
file = screen_save_part(working_directory + "\Screens\Screen_"+string(num)+".png",mouse_x-25,mouse_y-25,50,50);
if file != ""
{
sk=sprite_add("Screen_"+string(num)+".png",1,false,false,25,25);
sprite_index=sk;
num+=1;
}
 
B

Brleksak

Guest
SOLVED:

var file;
file = screen_save_part(working_directory + "\Screens\Screen_"+string(num)+".png",mouse_x-25,mouse_y-25,50,50);
if file != ""
{
sk=sprite_add(working_directory + "\Screens\Screen_"+string(num)+".png",1,false,false,25,25);
//sk=sprite_add(file,0,0,0,x,y);
sprite_index=sk;
num+=1;
}
 
Top