Files
phaser/examples/tile sprites/tilesprite2.php
T
2013-09-13 17:48:47 +01:00

50 lines
955 B
PHP

<?php
$title = "Tiling Sprites";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var s;
function preload() {
game.load.image('disk', 'assets/misc/starfield.jpg');
}
function create() {
s = game.add.tileSprite(0, 0, 800, 600, 'disk');
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.tilePosition.x += 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.tilePosition.x -= 8;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.tilePosition.y += 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.tilePosition.y -= 8;
}
}
})();
</script>
<?php
require('../foot.php');
?>