Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html>
  3.     <head>
  4.         <meta charset="UTF-8" />
  5.         <title>hello phaser!</title>
  6.         <script src="phaser.js" type="text/javascript"></script>
  7.         <style>
  8.         </style>        
  9.     </head>
  10.     <body>
  11.         <div id="phaser-example"></div>
  12.         <script type="text/javascript">
  13. // https://photonstorm.github.io/phaser-ce/        
  14. // https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#start
  15. // https://photonstorm.github.io/phaser-ce/#change-log
  16.  
  17.        
  18. var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
  19.  
  20. var emitter;
  21.  
  22. function preload() {
  23.  
  24.     game.load.image('diamond', '../assets/sprites/diamond.png');
  25.  
  26. }
  27.  
  28. function create() {
  29.  
  30.     game.physics.startSystem(Phaser.Physics.ARCADE);
  31.  
  32.     game.stage.backgroundColor = 0x337799;
  33.  
  34.     emitter = game.add.emitter(0, 0, 100);
  35.  
  36.     emitter.makeParticles('diamond');
  37.     //emitter.gravity =  200;
  38.     emitter.gravity =  new Phaser.Point(0, 100);
  39.  
  40.     game.input.onDown.add(particleBurst, this);
  41.  
  42. }
  43.  
  44. function particleBurst(pointer) {
  45.  
  46.     //  Position the emitter where the mouse/touch event was
  47.     emitter.x = pointer.x;
  48.     emitter.y = pointer.y;
  49.  
  50.     //  The first parameter sets the effect to "explode" which means all particles are emitted at once
  51.     //  The second gives each particle a 2000ms lifespan
  52.     //  The third is ignored when using burst/explode mode
  53.     //  The final parameter (10) is how many particles will be emitted in this single burst
  54.     emitter.start(true, 2000, null, 10);
  55.     //emitter.explode(2000, 10);
  56. }
  57.         </script>
  58.     </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement