Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                #phaser-demo
script(src="//cdnjs.cloudflare.com/ajax/libs/phaser/2.0.3/phaser.min.js")
              
            
!

CSS

              
                
              
            
!

JS

              
                var emitter, brokenEmitter;
var game = new Phaser.Game(400, 400, Phaser.AUTO, 'phaser-demo', {create: create, update: update});

var Particle = function(game,x, y, bitmapKey) {
  Phaser.Sprite.call(this, game,0,0, game.cache.getBitmapData(bitmapKey));
}

function create() {
  var bmd = game.add.bitmapData(4,4);
  bmd.ctx.fillStyle = '#e4c915';
  bmd.ctx.beginPath();
  bmd.ctx.fillRect(0, 0, 4, 4);
  bmd.ctx.closePath();
  game.cache.addBitmapData('yellowBlock', bmd);

  
  // this works
  var peeBlock = game.add.sprite(10, 10, game.cache.getBitmapData('yellowBlock'));
  
  // this emitter should explode with yellow blocks
  // on click
  // but it doesn't seem to work
  emitter = game.add.emitter(100, 100, 1000);
  emitter.particleClass = Particle;
  emitter.makeParticles('yellowBlock');
  
  // debug emitter, to make sure my code is correct
  brokenEmitter = game.add.emitter(100, 100, 1000);
  brokenEmitter.makeParticles('invalidKey');

  
  game.input.onDown.add(particleBurst, this);

}

function particleBurst(pointer) {
    console.log('click', 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);

}


function update() {
  brokenEmitter.emitParticle();
}
              
            
!
999px

Console