Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda