forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext on top.js
More file actions
61 lines (41 loc) · 1.06 KB
/
Copy pathtext on top.js
File metadata and controls
61 lines (41 loc) · 1.06 KB
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
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render : render });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var cursors;
var group;
var text;
var timer;
function create() {
game.stage.backgroundColor = '#007236';
for (var i = 0; i < 200; i++)
{
game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
text = game.add.text(0, 0, "Text Above Sprites", { font: "64px Arial", fill: "#00bff3", align: "center" });
timer = new Phaser.Timer(game);
timer.add(1000);
cursors = game.input.keyboard.createCursorKeys();
}
function update() {
timer.update();
if (cursors.up.isDown)
{
text.y -= 4;
}
else if (cursors.down.isDown)
{
text.y += 4;
}
if (cursors.left.isDown)
{
text.x -= 4;
}
else if (cursors.right.isDown)
{
text.x += 4;
}
}
function render() {
// game.debug.renderCameraInfo(game.camera, 32, 32);
}