phaser/wip/examples/body1.php
2013-09-13 17:48:47 +01:00

62 lines
No EOL
1.2 KiB
PHP

<!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() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.image('bunny', 'assets/sprites/bunny.png');
}
var bunny;
var bot;
function create() {
game.world._stage.backgroundColorString = '#182d3b';
bunny = game.add.sprite(500, game.world.centerY, 'bunny');
bunny.anchor.setTo(0.5, 0.5);
bot = game.add.sprite(150, game.world.centerY, 'bot');
bot.anchor.setTo(0.5, 0.5);
bot.animations.add('run');
bot.animations.play('run', 10, true);
game.add.tween(bot.scale).to({ x: 3, y: 3 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
}
function update() {
bunny.angle += 1;
bot.angle += 1;
}
function render() {
game.debug.renderSpriteCorners(bunny, true, true);
game.debug.renderSpriteCorners(bot, true, true);
game.debug.renderSpriteInfo(bunny, 20, 32);
game.debug.renderSpriteInfo(bot, 20, 132);
}
})();
</script>
</body>
</html>