RebusQuestionCard.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /************************************************************************
  2. * RebusQuestionCard.js
  3. ************************************************************************
  4. * Copyright (c) 2021 Pedro Tonini Rosenberg Schneider.
  5. *
  6. * This file is part of Alfabetiza.
  7. *
  8. * Alfabetiza is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Alfabetiza is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Alfabetiza. If not, see <https://www.gnu.org/licenses/>.
  20. *************************************************************************/
  21. class RebusQuestionCard extends Object2D
  22. {
  23. /** @type {TextureRes} */
  24. thumb = null;
  25. /** @type {String} */
  26. imgName = "";
  27. /** @type {Color} */
  28. fillColor = new Color(200, 200, 200);
  29. /** @type {Tween} */
  30. tween = null;
  31. _setup()
  32. {
  33. var sprite = new Sprite2D("sprite", this.thumb);
  34. sprite.width = 250;
  35. sprite.height = 250;
  36. sprite.setPosition(0, -75);
  37. this.addChild(sprite);
  38. this.scale = Vector2.ZERO();
  39. this.tween = new Tween("Tween");
  40. this.tween.interpolateProperty(this, "scale", PROPERTY_TYPE.VECTOR2, Vector2.ZERO(), Vector2.ONE(), 2, TRANS_TYPE.ELASTIC, EASE_TYPE.OUT);
  41. this.addChild(this.tween);
  42. }
  43. start()
  44. {
  45. this.tween.startAll();
  46. }
  47. _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
  48. {
  49. if (this.visible) this.tween.startAll();
  50. db.strokeWeight(10);
  51. db.rectMode(CENTER);
  52. db.fill(this.fillColor.getP5Color());
  53. db.rect(0, 0, 300, 400, 10, 10);
  54. db.textAlign(CENTER, CENTER);
  55. db.fill(0);
  56. db.textSize(40);
  57. db.text(this.imgName, 0, 100);
  58. }
  59. }