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

C

cheezy_squeezy

Guest
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.
 

samspade

Member
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.
 
J

Jdown79

Guest
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
 

CMAllen

Member
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.
 
Top