Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <title>hello phaser!</title>
- <script src="phaser.js" type="text/javascript"></script>
- <style>
- </style>
- </head>
- <body>
- <div id="phaser-example"></div>
- <script type="text/javascript">
- // https://photonstorm.github.io/phaser-ce/
- // https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#start
- // https://photonstorm.github.io/phaser-ce/#change-log
- var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
- var emitter;
- function preload() {
- game.load.image('diamond', '../assets/sprites/diamond.png');
- }
- function create() {
- game.physics.startSystem(Phaser.Physics.ARCADE);
- game.stage.backgroundColor = 0x337799;
- emitter = game.add.emitter(0, 0, 100);
- emitter.makeParticles('diamond');
- //emitter.gravity = 200;
- emitter.gravity = new Phaser.Point(0, 100);
- game.input.onDown.add(particleBurst, this);
- }
- function particleBurst(pointer) {
- // Position the emitter where the mouse/touch event was
- emitter.x = pointer.x;
- emitter.y = pointer.y;
- // 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);
- //emitter.explode(2000, 10);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement