Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
How to react with a single member of a group

I have a bunch of snowmen. They are all tween. When a player is captured by a specific snowman it is carried by it.

It is messy, inconvenient and time wasting to create every single sprite and set it to tween. I have learnt to use

const snowman = this.physics.add.group(); snowman.create(x, y, 'key');

But this does not give each snowman a name. When I set the player's X and Y when it is being carried, I set it to the x and y of the snowman that hit him. If I use the code above, it will obviously no longer work. What can do instead?

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Well without knowing your code. I would:

  • Create a variable to mark the snowman, that captured the player
  • and when the player collides with one snowman, set variable. Like this you know which snowman.

in the create function:

function create(){

    ...
    this.mainSnowMan = undefined; // at the begining no snowman is selected
    this.physics.add.collider(player, snowman, (player, currentsnowman) => {
        ...
        this.mainSnowMan = currentsnowman; // set the snowman that collided with the player
    });
    ...
}

documenation to the collider function https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Collider.html

and here is a link so man phaser physics examples: https://phaser.io/examples/v3/category/physics/arcade

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda