Is there a way to make an object's mask independent from the object's image_angle?

Discussion in 'Programming' started by cheezy_squeezy, Jun 1, 2018.

  1. cheezy_squeezy

    cheezy_squeezy Member

    Joined:
    Jun 27, 2016
    Posts:
    19
    Title.
    For example, I'm making a top down game where my character is a circle that points at the mouse, and my mask would rotate with the sprite, causing the player to get stuck in walls constantly. I solved this by drawing the sprite in the draw event with draw_sprite_ext and making it point at the mouse with that rather than setting the image_angle to point at the mouse in the step event, but I was wondering if there was a way around this.
    Cheers.
     
  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,019
    Honestly, the most straight forward way is to take over drawing the sprite yourself which is what you've already done. You can set the mask to another sprite manual and GMS 2 allows you to do it from the object detail box or whatever it is called, but even so the mask might rotate if you rotate the image angle. I'm not sure. Again, I think it is easier to just draw the sprite as you are doing.
     
    Jdown79 likes this.
  3. Jdown79

    Jdown79 Member

    Joined:
    Aug 21, 2016
    Posts:
    69
    the easiest way I've done it is to have skin object follow the player, And apply all movement to the player, all image_angle and attacks to the skin. It helped clean up the code a bit, and helped with perfect collisions
     
  4. CMAllen

    CMAllen Member

    Joined:
    Mar 2, 2017
    Posts:
    855
    Essentially to separate image_angle from your collision mask, you need to create your own 'image_angle' variable and use that instead when objects are drawn. A similar method would be used to separate x-scale and y-scale variables, too.

    Code:
    draw_sprite_ext(sprite_index,image_index,x,y,scale_x2,scale_y2, rotation2,c_white,image_alpha)
    This is, more or less, what draw_self() looks like behind the scenes, but with custom variables for the scale and rotation.
     

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