Ver Fonte

feature: game.add.text now accepts paragraphs

lairaalmas há 1 ano atrás
pai
commit
10c7cb8c10
1 ficheiros alterados com 6 adições e 1 exclusões
  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;