From f263813fb178afd1d84cf9cda80012c468aa43d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 9 Aug 2018 14:38:42 +0900 Subject: [PATCH] Add: Phaser text test --- study/PhaserText/index.html | 32 ++++++++++++++ study/PhaserText/text.js | 88 +++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 study/PhaserText/index.html create mode 100644 study/PhaserText/text.js diff --git a/study/PhaserText/index.html b/study/PhaserText/index.html new file mode 100644 index 0000000..3e3c1cd --- /dev/null +++ b/study/PhaserText/index.html @@ -0,0 +1,32 @@ + + + + + Phaser text test + + + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/study/PhaserText/text.js b/study/PhaserText/text.js new file mode 100644 index 0000000..3259a70 --- /dev/null +++ b/study/PhaserText/text.js @@ -0,0 +1,88 @@ +///////////////////////////// +// Main game + +var game = new Phaser.Game(1000, 800, Phaser.CANVAS, "RoundRectButton", + {preload:preload, create:create, update:update, render:render} +); + +var textAlign, textAlign2; + +function preload() { + // game.load.image('phaser', '../../resources/image/phaser.png'); + // game.load.spritesheet('button', './image/button_basic.png', 200, 100); +} + +function create() { + // var i = game.add.image(game.world.centerX, game.world.centerY + 70, 'phaser'); + // i.anchor.set(0.5); + game.stage.backgroundColor = '#4d4d4d'; + graphics = game.add.graphics(0, 0); + + printHowToPlay( + "가나다라마바사 아자차카타파하 \n \ + 가나다라마바사 아자차카타파하" + ); + + game.input.onDown.add(changeAlign, this); +} + +function changeAlign() { + console.log("print dummy"); + + + textAlign.text = "가나다라마바사 아자차카타파하 \n \ + 가나다라마바사 아자차카타파하"; + + // textAlign2.text = "가나다라마바사 아자차카타파하 \n \ + // 가나다라마바사 아자차카타파하"; +} + +function printHowToPlay(text) { + const style_origin = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; + let howToPlayText = game.add.text(0, 0, text, style_origin); + howToPlayText.setTextBounds(100, 100, game.world.width - 200, 200); + howToPlayText.stroke = "#333"; + howToPlayText.strokeThickness = 5; + + + var ipsum = "Click to change alignment\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Quid ergo aliud intellegetur nisi uti ne quae pars naturae neglegatur?\n\nSi longus, levis; Ita relinquet duas, de quibus etiam atque etiam consideret. Optime, inquam. Sed quanta sit alias, nunc tantum possitne esse tanta.\n\nQuid, si etiam iucunda memoria est praeteritorum malorum?"; + + var style = { font: "16px Arial", fill: "#fff", + align: "right", // the alignment of the text is independent of the bounds, try changing to 'center' or 'right' + boundsAlignH: "right", + boundsAlignV: "top", + wordWrap: true, wordWrapWidth: 300 }; + + textAlign = game.add.text(600, 100,ipsum, style); + + // textAlign.setTextBounds(16, 16, 768, 568); + textAlign.stroke = "#333333"; + textAlign.strokeThickness = 5; + + +/* + textAlign2 = game.add.text(200, 300, ipsum, style); + + // Center align + // textAlign2.anchor.set(0.5); + // textAlign2.align = 'right'; + // textAlign2.setTextBounds(16, 216, 368, 768); + + // Font style + // textAlign2.font = 'Arial Black'; + // textAlign2.fontSize = 50; + // textAlign2.fontWeight = 'bold'; + + // Stroke color and thickness + textAlign2.stroke = '#000000'; + textAlign2.strokeThickness = 5; + // textAlign2.fill = '#43d637'; + */ +} + + +function update() { +} + +function render() { +}