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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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