phaser/examples/particles/click burst.php

52 lines
1.2 KiB
PHP
Raw Normal View History

2013-09-15 20:45:00 +01:00
<?php
$title = "Click to Burst";
require('../head.php');
?>
<script type="text/javascript">
(function () {
2013-09-16 01:08:06 +01:00
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
2013-09-15 20:45:00 +01:00
2013-09-16 01:08:06 +01:00
var emitter;
2013-09-15 20:45:00 +01:00
function preload() {
game.load.image('diamond', 'assets/sprites/diamond.png');
}
function create() {
game.stage.backgroundColor = 0x337799;
2013-09-16 01:08:06 +01:00
emitter = game.add.emitter(0, 0, 200);
2013-09-15 20:45:00 +01:00
2013-09-16 01:08:06 +01:00
emitter.makeParticles('diamond');
emitter.gravity = 10;
2013-09-15 20:45:00 +01:00
game.input.onDown.add(particleBurst, this);
}
function particleBurst() {
2013-09-16 01:08:06 +01:00
// Position the emitter where the mouse/touch event was
emitter.x = game.input.x;
emitter.y = game.input.y;
2013-09-15 20:45:00 +01:00
2013-09-16 01:08:06 +01:00
// The first parameter sets the effect to "explode" which means all particles are emitted at once
// The second gives each particle a 2000ms lifespan
// The third is ignored when using burst/explode mode
// The final parameter (10) is how many particles will be emitted in this single burst
emitter.start(true, 2000, null, 10);
2013-09-15 20:45:00 +01:00
}
})();
</script>
<?php
require('../foot.php');
?>