Skip to content
RobotlegsJS framework integration with Phaser CE (Community Edition)
TypeScript JavaScript Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.vscode
example
src
static
test
.auditignore
.editorconfig
.gitignore
.istanbul.yml
.prettierrc
.publishrc
.travis.yml
CHANGELOG.md
LICENSE
README.md
karma.conf.js
package.json
tsconfig.example.json
tsconfig.json
tsconfig.test.json
tslint.example.json
tslint.json
tslint.test.json
webpack.config.js
webpack.example.config.js
yarn.lock

README.md

RobotlegsJS Phaser-CE Extension

GitHub license Gitter chat Build Status codebeat badge Maintainability Test Coverage npm version Greenkeeper badge styled with prettier

Integrate RobotlegsJS framework with Phaser-CE.

Installation

You can get the latest release and the type definitions using NPM:

npm install @robotlegsjs/phaser-ce --save-prod

Or using Yarn:

yarn add @robotlegsjs/phaser-ce

From version 0.2.0 of this package, the Phaser-CE dependency was moved to peerDependencies, allowing the final user to choose the desired version of the phaser-ce library on each project.

The @robotlegsjs/phaser-ce package is compatible with versions between the >=2.8.1 <3 version range of phaser-ce library.

As example, when you would like to use the version 2.8.1 of phaser-ce library, you can run:

npm install phaser-ce@2.8.1 reflect-metadata --save-prod

or

yarn add phaser-ce@2.8.1 reflect-metadata

Then follow the installation instructions of RobotlegsJS library to complete the setup of your project.

Dependencies

Peer Dependencies

Usage

/// <reference path="../node_modules/phaser-ce/typescript/phaser.d.ts" />

import "reflect-metadata";

import { Context, IContext, MVCSBundle } from "@robotlegsjs/core";
import { PhaserBundle, ContextStateManager } from "@robotlegsjs/phaser-ce";

import { StateKey } from "./constants/StateKey";

import { Boot } from "./states/Boot";
import { Preload } from "./states/Preload";
import { GameTitle } from "./states/GameTitle";
import { Main } from "./states/Main";
import { GameOver } from "./states/GameOver";

import { GameConfig } from "./config/GameConfig";
import { StateMediatorConfig } from "./config/StateMediatorConfig";

class Game extends Phaser.Game {

    private _context: IContext;

    constructor() {

        super(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.AUTO);

        this._context = new Context();
        this._context.install(MVCSBundle, PhaserBundle)
            .configure(new ContextStateManager(this.state))
            .configure(StateMediatorConfig)
            .configure(GameConfig)
            .initialize();

        this.state.add(StateKey.BOOT, Boot, false);
        this.state.add(StateKey.PRELOAD, Preload, false);
        this.state.add(StateKey.GAME_TITLE, GameTitle, false);
        this.state.add(StateKey.MAIN, Main, false);
        this.state.add(StateKey.GAME_OVER, GameOver, false);

        this.state.start(StateKey.BOOT);
    }
}

new Game();

See example

Running the example

Run the following commands to run the example:

npm install
npm start

or:

yarn install
yarn start

License

MIT

You can’t perform that action at this time.