Jump to content

how to know collision and no collision in phaser


Recommended Posts

i want to add buttons to div, when objects collide:

 this.game.physics.arcade.collide(this.player, this.eqgroup, this.wyborfunkcji, null, this);   

function after collide

wyborfunkcji: function(player, element){  if (element.funkcja == "krzeslof"){document.getElementById('FUNCTION').innerHTML= "<center><button id='button' >krzeslo</button></center>"; document.getElementById('button').addEventListener("click", this.buttonkrzeslo, false);}

function after click:

buttonkrzeslo: function(){console.log("wykonano");},

And this is working, but i want now delete button from div when collide stopped.


I try do to it that :

  update: function() {     if (!this.game.physics.arcade.collide(this.player, this.eqgroup, this.wyborfunkcji, null, this)){    document.getElementById('FUNCTION').innerHTML= '';    }

And it is working, but my button doesnt work now. When i dont add last code, my button if working.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...