var game = new Phaser.Game(640, 480, Phaser.AUTO, "", { preload: preload, create: create, update: update }); var cursor; var mujer; function preload() { game.load.spritesheet("mujer", document.getElementById("imgdata").textContent, 32, 64); } function create() { cursor = game.input.keyboard.createCursorKeys(); mujer = game.add.sprite(100, 100, "mujer"); mujer.frame = 10; mujer.animations.add("left", [24, 25, 26, 27, 28, 29, 30, 31], 10, true); mujer.animations.add("right", [16, 17, 18, 19, 20, 21, 22, 23], 10, true); mujer.animations.add("up", [0, 1, 2, 3, 4], 10, true); mujer.animations.add("down", [8, 9, 10, 11, 12], 10, true); } function update() { if (cursor.left.isDown) { mujer.animations.play("left"); mujer.x--; } else if (cursor.right.isDown) { mujer.animations.play("right"); mujer.x++; } else if (cursor.up.isDown) { mujer.animations.play("up"); mujer.y--; } else if (cursor.down.isDown) { mujer.animations.play("down"); mujer.y++; } else { mujer.animations.stop(); mujer.frame = 10; } }