Jump to content


Photo

alpha transparency and collision detection


  • Please log in to reply
7 replies to this topic

#1 TwoPointOw

TwoPointOw

    GMC Member

  • New Member
  • 16 posts

Posted 12 July 2011 - 05:15 PM

if ya apply alpha transparency to a sprite and make him half invisible, GM will still detect collision with that part as if its visible.
how do ya make it so GM does not detect collision with invisible part?
  • 0

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9322 posts
  • Version:Unknown

Posted 12 July 2011 - 05:27 PM

No, it won't. Not if you set precise collisions (and if there is more than one subimage, also check "separate collision masks").

-IMP ;) :)
  • 0

#3 TwoPointOw

TwoPointOw

    GMC Member

  • New Member
  • 16 posts

Posted 12 July 2011 - 05:53 PM

No, it won't. Not if you set precise collisions (and if there is more than one subimage, also check "separate collision masks").

-IMP ;) :)

i came a cross a glitch... is it possible if i apply a sprite with transparacy then collision detection will no work at all?
sry, i have to deal with other people gigantic scripts :S and i have no idea how they work
  • 0

#4 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9322 posts
  • Version:Unknown

Posted 13 July 2011 - 12:12 AM

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 ;) :)
  • 0

#5 TwoPointOw

TwoPointOw

    GMC Member

  • New Member
  • 16 posts

Posted 13 July 2011 - 09:29 AM

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 ;) :)

ig got it!
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 :(
  • 0

#6 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9322 posts
  • Version:Unknown

Posted 13 July 2011 - 09:58 AM

Well, that's because the mask is created when the alpha is different, so it takes into account pixels that are now invisible.

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 ;) :)
  • 0

#7 TwoPointOw

TwoPointOw

    GMC Member

  • New Member
  • 16 posts

Posted 13 July 2011 - 01:45 PM

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

#8 TwoPointOw

TwoPointOw

    GMC Member

  • New Member
  • 16 posts

Posted 13 July 2011 - 06:17 PM

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

wait..... theres also mask_index.. bouth of them *together* helped me:D FIXED!!!!!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users