Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

how to know collision and no collision in phaser


P4nch0
 Share

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

 Share

  • Recently Browsing   0 members

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