Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div style="font-family:'Luckiest Guy',cursive;visibility:hidden;opacity:0;position:fixed;">&nbsp;</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                // This example uses the Phaser 2.2.2 framework

// Copyright © 2015 Michael Dobekidis
// Licensed under the terms of the MIT License
var reg = {};
var GameState = function(game) {};

// Load images and sounds
GameState.prototype.preload = function() {
  this.load.image("bg", "http://i221.photobucket.com/albums/dd22/djmid71/Untitled-1_zpswmvh3qea.jpg");

};

// Setup the example
GameState.prototype.create = function() {
  // Set stage background to something sky colored
  this.game.stage.backgroundColor = 0x4488cc;
  this.game.add.tileSprite(0, -200, 750, 580, "bg");
	
  this.scoreLabel = game.add.text(200, 100, "Score Over: ",{
    font: "48px Luckiest Guy",
    fontSize: 48,
    fill: "#1e1e1e"
  });
  
  this.score = game.add.text(200, 100, "0",{
    font: "48px Luckiest Guy",
    fontSize: 48,
    fill: "#1e1e1e"
  });
  
  this.scoreLabel.update();
  this.score.update();
  this.scoreLabel.x = game.width/2 - this.scoreLabel.width/2-50;
  this.score.x = this.scoreLabel.x + this.scoreLabel.width+10;
  
  this.animateNumber("9000", this.updateScore, 10, 15);
};

// The update() method is called every frame
GameState.prototype.update = function() {

};

GameState.prototype.animateNumber = function(num, fn, step, speed, endFn) {
  var _step = step || 10;
  var _speed = speed || 10; // in seconds because this is total
  var repeats = Math.ceil(num / _step);
  var animSpeed = (_speed / repeats) * 1000; // in ms
  var _endFn = endFn || function() {
    game.time.events.remove(this);
  };
  var _timer = game.time.create(true);
  _timer.start();
  _timer.onComplete.add(_endFn);
  _timer.repeat(animSpeed, repeats, fn, this, [_step]);
};

GameState.prototype.updateScore = function(amount) {
  this.score.text = Number(this.score.text) + Number(amount);
  this.score.update();
}

var game = new Phaser.Game(750, 380, Phaser.CANVAS, 'game');
game.state.add('game', GameState, true);
              
            
!
999px

Console