AcrofonyQuestionCard.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. class AcrofonyQuestionCard extends Object2D
  2. {
  3. constructor(name)
  4. {
  5. super(name);
  6. /** @type {TextureRes} */
  7. this.thumb = null;
  8. /** @type {String} */
  9. this.imgName = "";
  10. /** @type {Color} */
  11. this.fillColor = new Color(200, 200, 200);
  12. /** @type {Tween} */
  13. this.tween = null;
  14. }
  15. _setup()
  16. {
  17. var sprite = new Sprite2D("sprite", this.thumb);
  18. sprite.width = 250;
  19. sprite.height = 250;
  20. sprite.setPosition(0, -75);
  21. this.addChild(sprite);
  22. this.scale = Vector2.ZERO();
  23. this.tween = new Tween("Tween");
  24. this.tween.interpolateProperty(this, "scale", PROPERTY_TYPE.VECTOR2, Vector2.ZERO(), Vector2.ONE(), 2, TRANS_TYPE.ELASTIC, EASE_TYPE.OUT);
  25. this.addChild(this.tween);
  26. }
  27. _update( /** @type {Number} */ delta)
  28. {
  29. if (this.visible) this.tween.startAll();
  30. }
  31. _draw( /** @type {Number} */ delta, /** @type {p5.Graphics} */ db)
  32. {
  33. db.strokeWeight(10);
  34. db.rectMode(CENTER);
  35. db.fill(this.fillColor.getP5Color());
  36. db.rect(0, 0, 300, 400, 10, 10);
  37. db.textAlign(CENTER, CENTER);
  38. db.fill(0);
  39. db.textSize(40);
  40. db.text(this.imgName, 0, 100);
  41. }
  42. }