-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd30d0e
commit d789285
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@echo off | ||
set main=./examples/bitmaptext/lineheight.js | ||
cd .. | ||
cd .. | ||
npm run dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import phaser from '../../../phaser/src/phaser.js'; | ||
|
||
class Demo extends Phaser.Scene { | ||
constructor() { | ||
super({ | ||
key: 'examples' | ||
}) | ||
} | ||
|
||
preload() { | ||
this.load.bitmapFont('gothic', 'assets/fonts/gothic.png', 'assets/fonts/gothic.xml'); | ||
} | ||
|
||
create() { | ||
var lines = []; | ||
for (var i = 0; i < 5; i++) { | ||
lines.push(i) | ||
} | ||
var s = lines.join('\n') | ||
var txt = this.add.bitmapText(0, 0, 'gothic', s).setFontSize(30).setLineSpacing(20) | ||
|
||
var textSize = txt.getTextBounds() | ||
console.log(textSize) | ||
|
||
var lineHeight = (textSize.lines.height + txt.lineSpacing) * textSize.scale; | ||
console.log(textSize.lines.height, txt.lineSpacing, textSize.scale, lineHeight) | ||
var graph = this.add.graphics() | ||
.lineStyle(3, 0xff0000) | ||
|
||
for (var i = 1; i < 6; i++) { | ||
graph.lineBetween(0, i * lineHeight, 100, i * lineHeight); | ||
} | ||
} | ||
|
||
update(time) { | ||
} | ||
} | ||
|
||
var config = { | ||
type: Phaser.AUTO, | ||
parent: 'phaser-example', | ||
width: 800, | ||
height: 600, | ||
scale: { | ||
mode: Phaser.Scale.FIT, | ||
autoCenter: Phaser.Scale.CENTER_BOTH, | ||
}, | ||
scene: Demo | ||
}; | ||
|
||
var game = new Phaser.Game(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters