inevitable037 Posted October 23, 2016 Share Posted October 23, 2016 I'm in the process of making a point and click demo. So far I have text that appears when you hover over a character. In addition, when you hover over, a "Next arrow image" button appears so that you can finish the dialogue. //I have the button declared globally for now. //I also have the dialogue and initialized as an array. var button; var ingramDialogue = [ "What's up?", "You know you should really consider doing something original.", "Let Policenauts be what it was.", "A series is good when people are left wanting more", "Why ruin that, ya know?", "" ]; In create() I have create(){ button = game.add.button(675, 450, 'white-arrow', null, this, 1, 0, 2); button.visible = false; } In update(), I have update(){ if(character.input.pointerOver()){ playCharacterDialogue(ingramDialogue); } } //Here is what playCharacterDialogue looks like //Essentially. It plays the initial line of dialogue //Then it allows the user to go to the next part of the dialogue with each click of the button that appeared //The function nextLine() then runs through each line of dialogue and prints it out as the user clicks the button //There is a counter within nextLine() that is used to determine which line should be printed, and if the dialogue is over. //THIS IS WHERE THE PROBLEM OCCURS //For some reason, instead of going to the next line of dialogue in the array, the //Program runs through the dialogue several times within milliseconds. //I think it has something to do with placing button.events.onInputDown.add in "update()", since that is checked every frame //What I'm trying to ask is. Is there something I can use other than "button.events.onInputDown.add" that would go through each line of the dialogue one click at a time? //Im not sure if this makes any sense. Any ideas would be appreciated function playCharacterDialogue(generalDialogue){ displayText.setText(generalDialogue[dialogueCounter], textStyle); button.visible = true; button.events.onInputDown.add(function(){ nextText(generalDialogue); }); index-alternate-version-2.html Link to comment Share on other sites More sharing options...
3ddy Posted October 24, 2016 Share Posted October 24, 2016 Why not add http://phaser.io/docs/2.2.2/Phaser.Events.html#onInputOver to character, instead those update loop you made? You are calling playCharacterDialogue every frame if pointer is over character Link to comment Share on other sites More sharing options...
Recommended Posts