phaser-shim-p2

2.4.8 • Public • Published

Phaser Shim

A shim to make Phaser HTML5 game engine from NPM work with Webpack, and build properly. (NOW WITH P2!!!!)

Phaser doesn't work with Webpack and require

Installation

npm install phaser-shim-p2 --save

Usage

This version can be used in the same way as the original phaser-shim. I also upgraded to the newest Phaser version (currently ^2.6.2).

Module

// game.js
 
require('phaser-shim-p2');
 
var game = new Phaser.Game(800, 600);

or ES6:

// Game.js
 
import 'phaser-shim-p2';
 
class Game extends Phaser.Game {
  constructor (width, height) {
    super(width, height);
  }
}
// game.js
 
import Game from './Game';
 
const game = new Game(800, 600);

or several per module:

import {Game, State} from 'phaser-shim-p2';

or TypeScript:

/// <reference path="../node_modules/phaser-shim-p2/typescript/phaser.comments.d.ts" />
 
declare module 'phaser-shim' {
  export = Phaser;
}

Webpack

// webpack.config.js
 
module: {
  // ...
  loaders: [{
    loader: 'script',// script-loader
    test: /(pixi|phaser).js/
  }],
  // ...
}

Development

If you want to use other Phaser version (old or new) in yourself:

  1. Fork this repo and git clone to local.
  2. npm install with node v4.x
  3. npm run build to building dist/pixi and dist/phaser
  4. now you can require or import your phaser-shim

Contributors

  • @AnimaMundi
  • @thosakwe

/phaser-shim-p2/

    Package Sidebar

    Install

    npm i phaser-shim-p2

    Weekly Downloads

    0

    Version

    2.4.8

    License

    MIT

    Last publish

    Collaborators

    • tobebuilds