1+ <!DOCTYPE HTML>
2+ <html>
3+ <head>
4+ <title>phaser.js - a new beginning</title>
5+ <?php
6+ require ('js.php ' );
7+ ?>
8+ </head>
9+ <body>
10+
11+ <script type="text/javascript">
12+
13+ (function () {
14+
15+ var game = new Phaser.Game(800, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });
16+
17+ var content = [
18+ " ",
19+ "photon storm presents",
20+ "a phaser production",
21+ " ",
22+ "Kern of Duty",
23+ " ",
24+ "directed by rich davey",
25+ "rendering by mat groves",
26+ " ",
27+ "03:45, November 4th, 2014",
28+ "somewhere in the north pacific",
29+ "mission control bravo ...",
30+ ];
31+
32+ var t = 0;
33+ var s;
34+ var index = 0;
35+ var line = '';
36+
37+ function preload() {
38+ game.load.image('cod', 'assets/pics/cod.jpg');
39+ }
40+
41+ function create() {
42+
43+ game.add.sprite(0, 0, 'cod');
44+
45+ var style = { font: "30pt Courier", fill: "#19cb65", stroke: "#119f4e", strokeThickness: 2 };
46+
47+ s = game.add.text(32, 380, '', style);
48+ t = game.time.now + 80;
49+
50+ }
51+
52+ function update() {
53+
54+ if (game.time.now > t && index < content.length)
55+ {
56+ // get the next character in the line
57+ if (line.length < content[index].length)
58+ {
59+ line = content[index].substr(0, line.length + 1);
60+ s.setText(line);
61+ t = game.time.now + 80;
62+ }
63+ else
64+ {
65+ t = game.time.now + 2000;
66+
67+ if (index < content.length)
68+ {
69+ index++;
70+ line = '';
71+ }
72+ }
73+ }
74+
75+ }
76+
77+ })();
78+
79+ </script>
80+
81+ </body>
82+ </html>
0 commit comments