Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!