Created
April 13, 2017 06:13
-
-
Save Majirefy/7d42f891c72af8c658dd4b12561de9dd to your computer and use it in GitHub Desktop.
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
import { Game, ScaleManager } from "phaser-ce"; | |
import Player from "./player"; | |
declare class WebFont { | |
public static load(options: object): void; | |
} | |
window.onload = () => { | |
WebFont.load({ | |
active: () => { | |
const game = new Game(800, 600, Phaser.AUTO, "phaser-example", { create, render }); | |
let text; | |
function create() { | |
game.scale.scaleMode = ScaleManager.SHOW_ALL; | |
game.scale.pageAlignHorizontally = true; | |
game.scale.pageAlignVertically = true; | |
// const bar = game.add.graphics(); | |
const bar = game.add.graphics(0, 100); | |
bar.beginFill(0x000000, 0.2); | |
bar.drawRect(0, 100, 800, 100); | |
const style = { font: "32px SongTi", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" }; | |
// The Text is positioned at 0, 100 | |
text = game.add.text(0, 0, "中文 2.6 text bounds", style); | |
// We'll set the bounds to be from x0, y100 and be 800px wide by 100px high | |
text.setTextBounds(0, 100, 800, 100); | |
} | |
function render() { | |
// game.debug.geom(text.textBounds); | |
} | |
}, | |
custom: { | |
families: ["SongTi"], | |
urls: ["assets/fonts/font.css"], | |
}, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment