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

[Solved]Is it possible to code for a function in timer.events directly


khleug35
 Share

Recommended Posts

Could I code for a function in timer.events directly??

here is my code 

Normally ,The following code is work for me!!!!!!!

game.time.events.add(Phaser.Timer.SECOND * 4, player_kill, this);

function player_kill() {
   player.kill();
}

 

but  Is it possible to code for a function in timer.events directly??? THX

Maybe like this , but the following code is not work, did I made a mistake?? Thank you so much

game.time.events.add(Phaser.Timer.SECOND * 4, player.kill(), this); //not work

 

Link to comment
Share on other sites

1 hour ago, samme said:

game.time.events.add(Phaser.Timer.SECOND * 4, player.kill, player);

 

THX, samme

this code is work for me !!! thx

but I am sorry about that, I have an other problem now.....

I want to change state on timer...........

the following code is not work, did I made a mistake?? Thank you so much

this.time.events.add(Phaser.Timer.SECOND * 4,  this.game.state.start('gameover'), this);//not work
this.time.events.add(Phaser.Timer.SECOND * 4, this.game.state.start, this, 'gameover');//not work
this.time.events.add(Phaser.Timer.SECOND * 4, this.game.state.start, 'gameover');//not work
this.time.events.add(3000, this.state.start, this, ['gameover']);//not work

 

Link to comment
Share on other sites

45 minutes ago, samme said:

this.time.events.add(Phaser.Timer.SECOND * 4, this.game.state.start, this.game.state, 'gameover');

 

Thank you very much!!!!samme, thank you for your help!!!!!!!!!

i am sorry about that i am so stupid......... ,but thank you for your help!!!!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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