Jump to content

A Dialog Based Game


m4rk2s
 Share

Recommended Posts

I want to add dialogs in my game sor here is the code

for the canvas i am using it's here  

 

var ChoiceState = function() {};

ChoiceState.prototype = {
  init: function() {
    this.stage.backgroundColor = '#b70eec'
    this.fontsReady = false
    this.game.stage.smoothed = false
  },

  fontsLoaded: function() {
    this.fontsReady = true
  },

  preload: function() {

  },

  create: function() {
      this.game.world.setBounds(0, 0, 160, 144)

      this.question = this.game.add.text(this.game.world.centerX, this.game.world.centerY - 30, 'What is the matrix ?', { font: "8px 'gameboy'", fill: '#000'});
      this.question.anchor.setTo(0.5);

      this.bluePill = this.game.add.text(this.game.world.centerX, this.game.world.centerY + 6, 'Blue Pill', { font: "6px 'gameboy'", fill: '#000'});
      this.bluePill.anchor.setTo(0.5);

      this.redPill = this.game.add.text(this.game.world.centerX, this.game.world.centerY - 6, 'Red PILL', { font: "6px 'gameboy'", fill: '#000'});
      this.redPill.anchor.setTo(0.5);

      this.upBtn = this.game.input.keyboard.addKey(Phaser.Keyboard.UP);
      this.upBtn.onDown.add(() => {
        //starts this state
        console.log("up");
      }, this);

      this.downBtn = this.game.input.keyboard.addKey(Phaser.Keyboard.DOWN);
      this.downBtn.onDown.add(() => {
        //starts the other state
        console.log("down");
      }, this);

  }
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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