forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnap.php
More file actions
50 lines (34 loc) · 1.33 KB
/
Copy pathsnap.php
File metadata and controls
50 lines (34 loc) · 1.33 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
<?php
$title = "Test Title";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
}
function create() {
game.add.sprite(0, 0, 'grid');
atari1 = game.add.sprite(128, 128, 'atari1');
atari2 = game.add.sprite(256, 256, 'atari2');
// Input Enable the sprites
atari1.inputEnabled = true;
atari2.inputEnabled = true;
// Allow dragging
// enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)
atari1.input.enableDrag();
atari2.input.enableDrag();
// Enable snapping. For the atari1 sprite it will snap as its dragged around and on release.
// The snap is set to every 32x32 pixels.
atari1.input.enableSnap(32, 32, true, true);
// For the atari2 sprite it will snap only when released, not on drag.
atari2.input.enableSnap(32, 32, false, true);
}
})();
</script>
<?php
require('../foot.php');
?>