1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 Using surface to hide part of sprite but having problems

Discussion in 'Programming' started by Zuljaras, Feb 22, 2019.

  1. Zuljaras

    Zuljaras Member

    Joined:
    Jan 16, 2017
    Posts:
    414
    So I want to make so when my player moves through an object and there will be a circle around him that will "delete" part of the sprite of the other object.

    I have done that with light but it was for the whole room and the surface created was with the size of the room and it was moving with the view.

    I want to make the surface to be drawn on top of the sprite of the object and move with the view.

    To summarize I want the surface to be always on the object I want to hide parts of.

    Here is the code:
    DRAW EVENT of Object I want to hide parts of:
    Code:
    size = 100;
    surface_set_target(surfacewithmask);
    
    draw_sprite(sprite_index,0,0,0);
    
    draw_set_blend_mode(bm_subtract);
    draw_set_colour(c_black);
    draw_circle(mouse_x,mouse_y,30,false);
    draw_set_blend_mode(bm_normal);
    surface_reset_target();
    draw_surface(surfacewithmask,view_xview,view_yview);
    The problem is that when I mouse over the object it does not hide it. It hides parts of the object when I mouse over on a totally different coordinates.

    Any help is appreciated!
     
  2. ampersandbear

    ampersandbear Member

    Joined:
    Sep 6, 2016
    Posts:
    27
    Surface uses relative coordinates, so instead of mouse_x you'd want to do mouse_x - x. Same for mouse_y, make sure it's mouse_y - y.
     
    Zuljaras likes this.
  3. Will i am

    Will i am Member

    Joined:
    Feb 1, 2017
    Posts:
    12
    replace:
    draw_circle(mouse_x,mouse_y,30,false);
    with:
    draw_circle(mouse_x - view_xview, mouse_y - view_yview, 30, false);
     
    Zuljaras likes this.
  4. Zuljaras

    Zuljaras Member

    Joined:
    Jan 16, 2017
    Posts:
    414
    Thank you both!!!
     

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