• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

draw and mask

Tales

Member
Hello!

I have a problem with collision between 2 objects.. A ray start from an object A, go to the cursor and if collision (or place_meeting, I tried the 2) with object B, something happen. The simple ray code is

GML:
draw_sprite_ext(spr_shiptirlazer01,-1,x,y,10,1,point_direction(x,y,obj_cursor.x,obj_cursor.y),-1,1)
and collision or place meeting in object B is

GML:
if place_meeting(x,y,obj_tirlazer01)
{life-=0.1
lockhero=1
instance_create(x,y,obj_fumee02)}
BUT I dont understand why this happen even the object A dont touch obj B!.. Im about 50 pixel away and its touching object B -.- . Visually sprite dont touch each other, so I guess its a mask problem..
But I verify the mask of both object, no problem.. I tried changing the yscalefor 0.1, its same.. I really dont know why this happen.... if someone have an idea?...


I understand a drawed object take the original mask sprite and if I dont have any sprite and only a drawed sprite, I have no mask from the draw (collision and place meeting do nothing)... I guess I misunderstood something.. but even this dont explain my collision problem..
 
Last edited:

Tales

Member
ok thanks but it dont works with collision... I mean its touching obj B but not "visually" I dont know what it touch, the mask of the ray is more little than the sprite................

Hoooooooooooooooooooooooo "both the assets in the collision have precise collisions flagged " sorry got one without flag.................. Its works fine now THANKS!

But I still wondering what there was collision, what mask it use if I dont check "precise"..... must be very deformed to touch a 50 pix object away..
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
But I still wondering what there was collision, what mask it use if I dont check "precise"..... must be very deformed to touch a 50 pix object away..
It will deform because of the angle. Bounding box collisions are based on the full rectangle that the sprite makes, so a line rotated 45º will have a square bbox. You can test this by giving a rectangular sprite a rectangular mask, and then in the draw event rotate it to face the mouse and draw the following:

GML:
draw_self();
draw_rectangle(bbox_left, bbox_top, bbox_right, bbox_top, bbox_right, bbox_bottom, bbox_left, bbox_bottom, true);
You'll see how the bounding box expands and contracts based on the total rectangular area that the sprite occupies. :)
 
Top