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

208
Visualizações
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 Respostas
Responde à pergunta

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 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