Jump to content

Phaser function re-use


xronn
 Share

Recommended Posts

Hi,

 

When I present the user with dialog in my game I want to call the function

dialog: function () {storyBackground = this.add.sprite(100, 35, 'text_scroll');storyBackground.fixedToCamera = true;questText = this.add.bitmapText(135, 100, 'text', 'Dam! Its hot out here! \n \n I want to get my tan on, is there anyway you could \n deliver this letter for me? \n \n Great, please take this letter north-west to a small \n camp and hand it to Jacob. He will reward you for \n your efforts. \n \n \n \n Press space to continue...', 14);questText.tint = 000000;}, 

 But I want to be able to pass the text into the function, else I'll have to create 100's of functions for all my dialog, what would be the best way of adding dialog so that I don't need to create 100s of functions each time.

Link to comment
Share on other sites

dialog: function (content) {storyBackground = this.add.sprite(100, 35, 'text_scroll');storyBackground.fixedToCamera = true;questText = this.add.bitmapText(135, 100, 'text', content, 14);questText.tint = 000000;}

Is that what you mean?

 

You could even pass the coordinates : 

dialog: function (x, y, content) {storyBackground = this.add.sprite(x, y, 'text_scroll');storyBackground.fixedToCamera = true;questText = this.add.bitmapText(x + 35, y + 65, 'text', content, 14);questText.tint = 000000;}

And so on...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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