xronn Posted October 21, 2015 Share Posted October 21, 2015 Hi, When I present the user with dialog in my game I want to call the functiondialog: 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 More sharing options...
Skeptron Posted October 21, 2015 Share Posted October 21, 2015 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 More sharing options...
xronn Posted October 21, 2015 Author Share Posted October 21, 2015 Aha, I literally was thinking exactly this after I posted, thanks for your help! Link to comment Share on other sites More sharing options...
Recommended Posts