AcrofonyTutorialDialogue.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. class AcrofonyTutorialDialogue extends Object2D
  2. {
  3. constructor(name)
  4. {
  5. super(name);
  6. /** @type {Button} */
  7. this.continueButton = null;
  8. /** @type {Timer} */
  9. this.timer;
  10. /** @type {String} */
  11. this.text = "";
  12. /** @type {number} */
  13. this.bgOpacity = 0;
  14. /** @type {number} */
  15. this.textOpacity = 0;
  16. }
  17. _initSignals()
  18. {
  19. this.addSignal("continue");
  20. }
  21. _setup()
  22. {
  23. this.continueButton = new Button("ContinueButton", "Continuar");
  24. this.continueButton.connect("mouseClicked", this, "_onContinueButtonMouseClicked");
  25. this.continueButton.hide();
  26. this.continueButton.setFontSize(40);
  27. this.continueButton.setPosition(1920 / 2 - this.continueButton.getSize().x / 2, 600);
  28. this.addChild(this.continueButton);
  29. }
  30. _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
  31. {
  32. switch (this.parent.tutorialStep)
  33. {
  34. case 0:
  35. this.bgOpacity = 0;
  36. this.textOpacity = 0;
  37. break;
  38. case 1:
  39. this.bgOpacity = min(this.bgOpacity + 150 * delta, 200);
  40. this.textOpacity = min(this.textOpacity + 150 * delta, 255);
  41. this.text = "Qual o primeiro pedacinho da palavra RELÓGIO?"
  42. if (this.textOpacity == 255) this.continueButton.show();
  43. break;
  44. case 2:
  45. this.continueButton.hide();
  46. this.bgOpacity = max(this.bgOpacity - 150 * delta, 0);
  47. this.textOpacity = max(this.textOpacity - 150 * delta, 0);
  48. this.text = "Qual o primeiro pedacinho da palavra RELÓGIO?"
  49. break;
  50. case 3:
  51. this.bgOpacity = 0;
  52. this.textOpacity = 0;
  53. break;
  54. case 8:
  55. this.bgOpacity = min(this.bgOpacity + 150 * delta, 200);
  56. this.textOpacity = min(this.textOpacity + 150 * delta, 255);
  57. this.text = "O primeiro pedacinho de RELÓGIO é RE\n\nAgora é sua vez!"
  58. if (this.textOpacity == 255) this.continueButton.show();
  59. }
  60. db.noStroke();
  61. db.fill(0, this.bgOpacity);
  62. db.rectMode(CENTER);
  63. db.rect(db.width / 2, db.height / 2, 1800, 600, 40, 40);
  64. db.textAlign(CENTER, CENTER);
  65. db.fill(255, this.textOpacity);
  66. db.textSize(40);
  67. db.text(this.text, db.width / 2, db.height / 2 - 100);
  68. }
  69. _onContinueButtonMouseClicked()
  70. {
  71. this.emitSignal("continue");
  72. }
  73. }