Sprite.loadTexture added.

This commit is contained in:
photonstorm
2013-10-10 09:03:38 +01:00
parent f10f9324ad
commit a7230aa769
16 changed files with 2079 additions and 2307 deletions
+51
View File
@@ -0,0 +1,51 @@
<?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');
?>