mirror of
https://github.com/wassname/phaser.git
synced 2026-08-11 11:23:06 +08:00
Sprite.loadTexture added.
This commit is contained in:
@@ -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');
|
||||
?>
|
||||
Reference in New Issue
Block a user