Mummy attack :)

This commit is contained in:
Richard Davey
2013-08-30 18:56:10 +01:00
parent e77f5da2cd
commit 54d98944e4
6 changed files with 112 additions and 53 deletions
+10 -5
View File
@@ -25,21 +25,26 @@
function create() {
bunny = game.add.sprite(-40, 100, 'ms');
bunny = game.add.sprite(40, 100, 'ms');
bunny.animations.add('walk');
bunny.animations.play('walk', 50, true);
// bunny.scale.x = 8;
// bunny.scale.y = 8;
game.add.tween(bunny).to({ x: game.width }, 10000, Phaser.Easing.Linear.None, true);
}
// update isn't called until 'create' has completed. If you need to process stuff before that point (i.e. while the preload is still happening)
// then create a function called loadUpdate() and use that
function update() {
bunny.postUpdate();
if (bunny.x >= 300)
{
bunny.scale.x += 0.01;
bunny.scale.y += 0.01;
}
}
})();
+61
View File
@@ -0,0 +1,61 @@
<!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.AUTO, '', { preload: preload, create: create, update: update });
var timer = 0;
var total = 0;
function preload() {
// 37x45 is the size of each frame
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
// blank frames at the end, so we tell the loader how many to load
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
function create() {
releaseMummy();
}
function releaseMummy() {
var mummy = game.add.sprite(-(Math.random() * 800), game.world.randomY, 'mummy');
mummy.animations.add('walk');
mummy.animations.play('walk', 50, true);
game.add.tween(mummy).to({ x: game.width + (1600 + mummy.x) }, 20000, Phaser.Easing.Linear.None, true);
total++;
timer = game.time.now + 100;
}
function update() {
if (total < 200 && game.time.now > timer)
{
releaseMummy();
}
}
})();
</script>
</body>
</html>