mirror of
https://github.com/wassname/phaser.git
synced 2026-07-28 11:23:50 +08:00
73 lines
1.4 KiB
PHP
73 lines
1.4 KiB
PHP
<?php
|
|
$title = "Little animated story";
|
|
require('../head.php');
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {preload:preload,create: create });
|
|
|
|
|
|
function preload() {
|
|
game.load.spritesheet('pig', 'assets/sprites/invaderpig.png', 124, 104);
|
|
game.load.image('starfield', 'assets/misc/starfield.jpg');
|
|
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
|
|
|
}
|
|
|
|
var mushroom,
|
|
pig,
|
|
pigArrives,
|
|
s;
|
|
|
|
function create() {
|
|
|
|
game.add.tileSprite(0,0,800,600,'starfield');
|
|
|
|
pig=game.add.sprite(-50,200,'pig',1);
|
|
|
|
pig.scale.setTo(0.5,0.5);
|
|
|
|
mushroom=game.add.sprite(380,200,'mushroom');
|
|
mushroom.anchor.setTo(0.5,0.5);
|
|
|
|
pigArrives= game.add.tween(pig);
|
|
|
|
pigArrives.to({x:150}, 1000, Phaser.Easing.Bounce.Out);
|
|
pigArrives.onComplete.add(firstTween, this);
|
|
pigArrives.start();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
function firstTween() {
|
|
|
|
s=game.add.tween(mushroom.scale);
|
|
s.to({x : 2,y:2}, 1000, Phaser.Easing.Linear.None);
|
|
s.onComplete.addOnce(theEnd, this);
|
|
s.start();
|
|
|
|
}
|
|
|
|
function theEnd() {
|
|
|
|
e=game.add.tween(pig);
|
|
|
|
e.to({x:-150}, 1000, Phaser.Easing.Bounce.Out);
|
|
e.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<?php
|
|
require('../foot.php');
|
|
?>
|