1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- class AcrofonyGameDialogue extends Object2D
- {
- constructor(name)
- {
- super(name);
-
- this.continueButton = null;
-
- this.timer;
-
- this.suffix = "";
-
- this.bgOpacity = 0;
-
- this.textOpacity = 0;
- }
- _initSignals()
- {
- this.addSignal("endGame");
- }
- _setup()
- {
- this.timer = new Timer("Timer", 2, false, true);
- this.timer.connect("timeout", this, "_onTimerTimeout");
- this.addChild(this.timer);
- this.continueButton = new Button("ContinueButton", "Continuar");
- this.continueButton.setFontSize(40);
- this.continueButton.setPosition(1920 / 2 - this.continueButton.getSize().x / 2, 600);
- this.continueButton.connect("mouseClicked", this, "_onContinueButtonClicked");
- this.addChild(this.continueButton);
- this.continueButton.hide();
- }
- _draw( delta, db)
- {
- if (this.parent.gameFinished)
- {
- this.timer.start();
- db.noStroke();
- db.fill(0, min(this.bgOpacity += 75 * delta, 200));
- db.rectMode(CENTER);
- db.rect(db.width / 2, db.height / 2, 1800, 600, 40, 40);
- db.textAlign(CENTER, CENTER);
- db.fill(255, min(this.textOpacity += 80 * delta, 255));
- db.textSize(40);
- this.parent.points > 1 ? this.suffix = "S" : this.suffix = "";
- db.text(`PARABÉNS, NÍVEL CONCLUÍDO\n\nVOCÊ GANHOU ${this.parent.points} PONTO${this.suffix}!`, db.width / 2, db.height / 2 - 100);
- }
- }
- _onTimerTimeout()
- {
- this.continueButton.show();
- }
- _onContinueButtonClicked()
- {
- this.emitSignal("endGame");
- }
- }
|