alpha transparency and collision detection
#1
Posted 12 July 2011 - 05:15 PM
how do ya make it so GM does not detect collision with invisible part?
#2
Posted 12 July 2011 - 05:27 PM
-IMP
#3
Posted 12 July 2011 - 05:53 PM
i came a cross a glitch... is it possible if i apply a sprite with transparacy then collision detection will no work at all?No, it won't. Not if you set precise collisions (and if there is more than one subimage, also check "separate collision masks").
-IMP![]()
sry, i have to deal with other people gigantic scripts :S and i have no idea how they work
#4
Posted 13 July 2011 - 12:12 AM
-IMP
#5
Posted 13 July 2011 - 09:29 AM
ig got it!It'll only happen if you've messed up the collision mask somehow (i.e. by turning the alpha tolerance up to 255 or making the mask dimensions 0x0 or 1x1 or something). Chances are, if you're using a script for collision detection and it's not working, the problem is in the script's code, not in the sprite's mask.
-IMP![]()
if you apply alpha transparency to a sprite via alpha_set_from_sprite() then that sprite's invisible part will collide if using place_meeting()
and i dont need that part to collide
#6
Posted 13 July 2011 - 09:58 AM
If you want to reset the mask, after using sprite_set_alpha_from_sprite, try calling this function:
sprite_collision_mask(ind,sepmasks,bboxmode,bbleft,bbright,bbtop,bbbottom,kind,tolerance) Changes the collision mask for the sprite with index ind. sepmasks indicates whether there must be separate collision masks for all subimages. bboxmode is the bounding box mode (0=automatic, 1=full image, 2=user defined). bbleft, bbright, bbtop, bbbottom indicate the bounding box in case of user defined bounding box. You can use 0 for all these values in the other cases. kind is the kind of mask (0=precise, 1=bounding box, 2=disk, 3=diamond). tolerance indicates the tolerance in the transparency value (0=no tolerance, 255=full tolerance).
Basically, it resets the mask.
-IMP
#7
Posted 13 July 2011 - 01:45 PM
but a minute of your time..
i had it working.. but i messed up again somehow:S
i am applying this:
//make new var
sprite_index_copy = sprite_duplicate(sprite_index)
//apply transparency
sprite_set_alpha_from_sprite(sprite_index_copy,MY_BLACK_N_WHITE_SPRITE);
//apply your code
sprite_collision_mask(sprite_index_copy,0,0,0,0,0,0,0,0)
i alse double check and drawing sprite_index_copy on screen.. and indeed it is half invisible, and half visible.
but the invisible part collides again :S:S:S:S:S:S i must have missed something:S
#8
Posted 13 July 2011 - 06:17 PM
wait..... theres also mask_index.. bouth of them *together* helped me:D FIXED!!!!!you, your method totaly works:D thanks
but a minute of your time..
i had it working.. but i messed up again somehow:S
i am applying this:
//make new var
sprite_index_copy = sprite_duplicate(sprite_index)
//apply transparency
sprite_set_alpha_from_sprite(sprite_index_copy,MY_BLACK_N_WHITE_SPRITE);
//apply your code
sprite_collision_mask(sprite_index_copy,0,0,0,0,0,0,0,0)
i alse double check and drawing sprite_index_copy on screen.. and indeed it is half invisible, and half visible.
but the invisible part collides again :S:S:S:S:S:S i must have missed something:S
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











