1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

[SOLVED] can I draw an instance's collision mask

Discussion in 'Programming' started by Mr Errorz, Oct 5, 2016.

Tags:
  1. Mr Errorz

    Mr Errorz Member

    Joined:
    Jun 21, 2016
    Posts:
    222
    I want to see the collision mask of a certain instance while running the game,
    preferably overlaid on top of the instance's sprite..
    is there a way to draw it on screen while the game is running?
     
  2. ph101

    ph101 Member

    Joined:
    Jun 20, 2016
    Posts:
    416
    Yes you can:

    Code:
    draw_sprite_ext(mask_index,0,x,y,1,1,0,c_aqua,0.5);   
    
    obviously changing the parameters as need be, and ensuring you have actually set your object's mask_index.
     
    Mr Errorz likes this.
  3. Mr Errorz

    Mr Errorz Member

    Joined:
    Jun 21, 2016
    Posts:
    222
    cool, thanks!
     
  4. Mr Errorz

    Mr Errorz Member

    Joined:
    Jun 21, 2016
    Posts:
    222
    actually not what I was looking for,
    but it got me to what I needed, and that's drawing the bbox of the sprite.

    went for something like-
    draw_set_alpha(0.5);
    draw_rectangle_colour(bbox_left,bbox_top,bbox_right,bbox_bottom,c_red,c_red,c_red,c_red,false);
     
  5. ph101

    ph101 Member

    Joined:
    Jun 20, 2016
    Posts:
    416
    Ok glad that works, it's not technically the collision mask, but the boundaries of the sprite you are drawing, which may or may not be the same depending on if it's a precise or imprecise collision check you are doing, and then how have the collision checks set for the sprite in the GM sprite editor in question. Glad it helped anyway.
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,026
    Actually @ph101 it's still the collision mask. The bounding box is the boundaries of the collision mask, not the sprite, technically. The boundaries of the sprite are x-sprite_xoffset, y-sprite_yoffset, x-sprite_xoffset+sprite_width, y-sprite_yoffset+sprite_height.
     
    ph101 likes this.
  7. ph101

    ph101 Member

    Joined:
    Jun 20, 2016
    Posts:
    416
    @TheouAegis Aha good point! So if using imprecise collision detecting then bbox would define the boundries checked for collision, but they would be determined by the mask_index if set or mask of the the sprite if set...
     

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