forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpixelpick3.php
More file actions
114 lines (83 loc) · 2.48 KB
/
Copy pathpixelpick3.php
File metadata and controls
114 lines (83 loc) · 2.48 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
$title = "Test Title";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
game.load.image('stars', 'assets/misc/starfield.jpg');
}
var b;
var camSpeed = 8;
var s;
function create() {
// Make our world big ...
game.world.setSize(4000, 2000);
// Scrolling background
s = game.add.tileSprite(0, 0, 800, 600, 'stars');
s.scrollFactor.setTo(0, 0);
b = game.add.sprite(200, 200, 'mummy');
b.anchor.setTo(0.5, 0.5);
b.scale.setTo(6, 6);
b.animations.add('walk');
b.animations.play('walk', 5, true);
b.body.velocity.setTo(50, 0);
// Listen for input events on this sprite
b.inputEnabled = true;
// Check the pixel data of the sprite
b.input.pixelPerfect = true;
// Enable the hand cursor
b.input.useHandCursor = true;
b.events.onInputOver.add(overSprite, this);
b.events.onInputOut.add(outSprite, this);
}
function overSprite() {
console.log('over');
}
function outSprite() {
console.log('out');
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= camSpeed;
if (!game.camera.atLimit.x)
{
s.tilePosition.x += camSpeed;
}
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += camSpeed;
if (!game.camera.atLimit.x)
{
s.tilePosition.x -= camSpeed;
}
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= camSpeed;
if (!game.camera.atLimit.y)
{
s.tilePosition.y += camSpeed;
}
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += camSpeed;
if (!game.camera.atLimit.y)
{
s.tilePosition.y -= camSpeed;
}
}
}
function render() {
game.debug.renderSpriteInputInfo(b, 32, 32);
}
})();
</script>
<?php
require('../foot.php');
?>