Jump to content

Button-Callback from string


cheshirepuss42
 Share

Recommended Posts

I'm trying to make a game which is basically a grid where the player moves across. When the player moves on certain squares the first panel of a dialog tree will be presented: Some text, an image and some choices. The dialog trees I want to be able to make in JSON.
For the choices there is a text and an action to be taken on that choice. I made the choices using Phaser.button, which has callback:Function as a parameter. Things I want to be able to do are fx. modify player health, spawn enemy, modify energy, so all kinds of stuff.
I don't really have a clue how to do this in phaser. I understand that i need some reference to the gamedata, but how to run a method like game.player.modifyhealth(-10) from something like this {callback:"game.player.modifyhealth",mod:-10} when i press a certain button? So what do i pass to Phaser.button as callback?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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