Search the Community
Showing results for tags 'character interaction'.
-
Hello all, I've only been Phaser for about 2 weeks now, and I'm really enjoying using it! I've taken the basic tutorial http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game and have modified it to add enemy AI, added a timer, and divided it all up into their own files for each of the states (preload, update, play, etc). I would like to have it so when the game starts, another sprite is added to the game and has a popup bubble with some dialog that the user can cycle through (using the 'a' button, or what have you). After the dialog finishes, then the enemy AI begin to move and the timer starts. As for the cutscene, what would be the best way to go about this? I've gotten it to cycle through one line of dialog using this code: var dialog;function create(){ // Beginning dialog for the cutscene var diaText = "Hello!"; var subtext = "press \'a\'"; var style = {font: "22px Arial", fill:"white", align: "center"}; var style2 = {font: "10px Arial", fill:"white", align: "center"}; dialog = game.add.text(game.world.centerX-300, 400, diaText, style); var tSub = game.add.text(game.world.centerX-300, 425, subtext, style2);}function update(){ // Cycle through the next line of dialog if(this.game.input.keyboard.justPressed(Phaser.Keyboard.A)){ dialog.setText('It\'s nice to meet you!'); }} My questions come down: What is the best way to create the cutscene? Inside of the play state of the game, or creating a separate state for the cutscene? Also, what is the best way to get the dialog? I was considering using a file reader of some type and having a loop that reads each line of text into an array. Then just loading up each line on the key press into the dialog.setText() until the array ends, but I don't want to try and code all of that first if there is a better way.