phaser/wip/examples/camera_cull1.php

68 lines
1.2 KiB
PHP
Raw Normal View History

2013-09-01 18:52:50 +00:00
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
2013-09-02 23:42:17 +00:00
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
2013-09-01 18:52:50 +00:00
}
var s;
function create() {
2013-09-02 23:42:17 +00:00
game.world._stage.backgroundColorString = '#182d3b';
2013-09-01 18:52:50 +00:00
2013-09-02 23:42:17 +00:00
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
2013-09-01 18:52:50 +00:00
}
function update() {
2013-09-02 23:42:17 +00:00
s.rotation += 0.01;
2013-09-01 18:52:50 +00:00
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
2013-09-02 23:42:17 +00:00
s.x -= 4;
2013-09-01 18:52:50 +00:00
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
2013-09-02 23:42:17 +00:00
s.x += 4;
2013-09-01 18:52:50 +00:00
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
2013-09-02 23:42:17 +00:00
s.y -= 4;
2013-09-01 18:52:50 +00:00
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
2013-09-02 23:42:17 +00:00
s.y += 4;
2013-09-01 18:52:50 +00:00
}
}
function render() {
2013-09-02 23:42:17 +00:00
game.debug.renderSpriteCorners(s, true, true);
game.debug.renderSpriteInfo(s, 20, 32);
2013-09-01 18:52:50 +00:00
}
})();
</script>
</body>
</html>