forked from hiloteam/Hilo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBitmapText.html
61 lines (56 loc) · 2.01 KB
/
BitmapText.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, width=device-width, minimum-scale=1, maximum-scale=1" />
<title>BitmapText - Hilo Example</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="../build/standalone/hilo-standalone.min.js"></script>
<script type="text/javascript" src="../build/flash/hilo-flash.min.js" data-auto="true"></script>
</head>
<body onload="init();">
<div id="header">
<h1>BitmapText</h1>
<p>BitmapText类提供使用位图文本的功能。当前仅支持单行文本。</p>
</div>
<div id="game-container"></div>
<script type="text/javascript" src="js/demo.js"></script>
<script type="text/javascript">
function init(){
var BitmapText = Hilo.BitmapText;
var Stage = Hilo.Stage;
var Container = Hilo.Container;
var Ticker = Hilo.Ticker;
//init stage
var stage = new Stage({
renderType:renderType,
container: gameContainer,
width: stageWidth,
height: stageHeight
});
//start stage ticker
var ticker = new Ticker(20);
ticker.addTick(stage);
ticker.start();
var container = new Container({
x:winWidth * .5,
y:0,
background:"#aaa",
width:400,
height:400
}).addTo(stage);
var textImage = new Image();
textImage.onload = function(){
var bmp = new BitmapText({
glyphs:BitmapText.createGlyphs("0123456789 ", textImage),
y:0,
x:0,
textAlign:"center",
letterSpacing:10
}).setText("967542 2").addTo(container);
};
textImage.src = "./images/num.png";
}
</script>
</body>
</html>