Browse Source

feature: game.add.text now accepts paragraphs

lairaalmas 1 year ago
parent
commit
10c7cb8c10
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/js/gameMechanics.js

+ 6 - 1
src/js/gameMechanics.js

@@ -933,7 +933,12 @@ const game = {
       context.textAlign = cur.align;
       context.fillStyle = cur.fill;
       // Text
-      context.fillText(cur.name, x, y);
+      const paragraphs = String(cur.name).split('\n');
+      let newY = y;
+      for (let line in paragraphs) {
+        context.fillText(paragraphs[line], x, newY);
+        newY += 48;
+      }
       // End
       context.shadowBlur = 0;
       context.globalAlpha = 1;