I’m currently creating a space game and in this scene the two characters have a dialogue with each other. Using the spacebar to trigger the first dialogue and second dialogue boxes. I was able to trigger the first dialogue boxes but when I press the spacebar again It will not transition to the second dialogue boxes. Below is my code.
// code here:
var Intro = pc.createScript('intro');
// initialize code called once per entity
Intro.prototype.initialize = function() {
this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this);
this.Slide1Hero = this.app.root.findByName("Slide1Hero");
this.Slide1Image = this.app.root.findByName("Slide1Image");
this.Slide2Enemy = this.app.root.findByName("Slide2Enemy");
this.Slide2Image = this.app.root.findByName("Slide2Image");
this.Slide3Image = this.app.root.findByName("Slide3Image");
this.Slide4Image = this.app.root.findByName("Slide4Image");
slidecounter = 0;
};
// update code called every frame
Intro.prototype.update = function(dt) {
};
Intro.prototype.onKeyDown = function (event) {
if (event.key === pc.KEY_SPACE && slidecounter == 1) {
this.Slide1Hero.enabled = true;
this.Slide1Image.enabled = true;
this.Slide2Enemy.enabled = true;
this.Slide2Image.enabled = true;
slidecounter = 2;
}
if (event.key === pc.KEY_SPACE && slidecounter == 0) {
this.Slide3Image.enabled = true;
this.Slide4Image.enabled = true;
slidecounter = 1;
}
};