1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

What's wrong with my screenshot code?

Discussion in 'Programming' started by Brleksak, Sep 1, 2017.

  1. Brleksak

    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
     
  2. Tsa05

    Tsa05 Member

    Joined:
    Jun 21, 2016
    Posts:
    560
    Well, at a glance, you save this:
    "\Screens\Screen_"+string(num)+".png"
    and add this:
    "Screen_"+string(num)
     
  3. Brleksak

    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;
    }
     
  4. Brleksak

    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;
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice