phaser/examples/animation/change texture.php
2013-10-10 09:03:38 +01:00

51 lines
No EOL
885 B
PHP

<?php
$title = "Changing a Sprite Texture";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
var bot;
function create() {
bot = game.add.sprite(200, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 15, true);
game.input.onDown.addOnce(changeMummy, this);
}
function changeMummy() {
bot.loadTexture('mummy', 0);
bot.animations.add('walk');
bot.animations.play('walk', 30, true);
}
function render() {
game.debug.renderSpriteBounds(bot);
}
</script>
<?php
require('../foot.php');
?>