Obrigado por visitar a The Game Makers Brasil 😁 Use o fórum de Dúvidas para fazer perguntas. Se está em busca de aprender dê uma olhada nos tutoriais.

[RESOLVIDO]como se usa a função sprite_collision_mask()?

Perguntas? A comunidade te ajuda a resolver.
Avatar do usuário
Cambalinho
Membro
Membro
Reações: 0
Mensagens: 59

[RESOLVIDO]como se usa a função sprite_collision_mask()?

Mensagem por Cambalinho » Dom Nov 26, 2017 12:22 pm

a gente pode alterar a mascara de colisão usando a função sprite_collision_mask().
mas eu não entendo como se usa.
"Description
With this function you can set the type of collision mask that a sprite should have. If you select either automatic, or precise, then the bounding box values can be set to 0, however for a user defined mask you will have to set these values.

The bounding box is always a relative value, based on the (0,0) position being the top left corner of the sprite (irrespective of the x and y origin).

The kind of mask sets the general shape for the mask itself, although if you have a user defined bounding box, you may end up with a "cut off" mask that is not complete.

Finally, tolerance is used to define how precise the precise mask is, with a tolerance of 0 meaning that the mask will follow every single pixel that has a transparency over 0, while other values will shift the collision mask perimeter depending on the transparency of the pixels.

NOTE: This function is only useful for bitmap sprites and will not work with SWF or JSON (Spine) sprites.

NOTE: This function will only work on duplicated sprites and not directly on pre-made resources. you can duplicate sprites using the function sprite_duplicate."

mas não entendo como usar esta função. os argumentos bbleft e bbtop(por esta ordem), podem ser obtidos pelas variavéis da instancia: bbox_left e bbox_top. 
como calcular o bbox_right e bbox_bottom?
posso meter bbox_left - distance?  preciso converter distance antes de usar?
- "distance" é 1 variavel que uso para distancia entre jogador e 1 parede(por exemplo). 
alguem me pode explicar, o Manual é confuso.
Editado pela última vez por Cambalinho em Sex Dez 01, 2017 2:02 pm, em um total de 1 vez.

Avatar do usuário
Cambalinho
Membro
Membro
Reações: 0
Mensagens: 59

Re: como se usa a função sprite_collision_mask()?

Mensagem por Cambalinho » Sex Dez 01, 2017 2:01 pm

ja entendi. os limites desta função é o tamanho da sprite. ou seja temos 1º de alterar o tamanho da sprite para poder usar esta função.
muito obrigado

Trancado

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 5 visitantes