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

219
Vistas
there are two object on view both are overlapping each other but event not occurs in phaser 3 javascript

What I want is when the player overlaps with the coin, the coin disappears, but its not for some reason and I don't why the cutcoin function is not called.

function create() {
    var  healthGroup = this.physics.add.staticGroup({
      key: 'ycoin',
      frameQuantity: 10,
      immovable: true
    });
    
    var children = healthGroup.getChildren();
    
    for (var i = 0; i < children.length; i++)
    {
      var x = Phaser.Math.Between(50, 750);
      var y = Phaser.Math.Between(50, 550);
      children[i].setPosition(x, y);
    }

    healthGroup.refresh();
    moveCoin = this.add.sprite(60, 340, "ycoin").setInteractive();
  
    this.input.keyboard.on('keydown-A', () => {   
      moveCoin.allname = "green"
      diceNumber = 1
      moveCoinStep()
      setTimeout(() => {
        this.physics.add.overlap(moveCoin,healthGroup, 
          cutcoin,null,this)
      }, 1000);
    })
}

function cutcoin(movecoin1, healthGroup) {
  console.log('++++++', moveCoin, healthGroup)     
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Don't add this line

this.physics.add.overlap(moveCoin,healthGroup,cutcoin,null,this)

inside keyboard event or on timeout. overlap function is only triggered when overlap occur not on definition. so write the add overlap line outside the keyboard event. And check the console for any error.

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