Skip to content

Commit

Permalink
Merge pull request #52 from RobotlegsJS/phaser
Browse files Browse the repository at this point in the history
Migrate to Phaser v3
  • Loading branch information
tiagoschenkel authored Aug 7, 2018
2 parents 741c6a9 + a0ca710 commit 0a014fc
Show file tree
Hide file tree
Showing 78 changed files with 60,766 additions and 978 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ typings/
dist
dist-test
lib
lib-example
lib-test
src/**/*.js
src/**/*.js.map
test/**/*.js
test/**/*.js.map
test/**/*.js.map

#os
.DS_Store
.AppleDouble
.LSOverride
9 changes: 8 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
/dist-test
/docs
/example
/lib-example
/lib-test
/not-ported-extensions
/src
/static
/test
/transpiled-code
/typings
Expand All @@ -17,8 +19,10 @@ CONTRIBUTING.md
ISSUE_TEMPLATE.md
PULL_REQUEST_TEMPLATE.md
karma.conf.js
tsconfig.example.json
tsconfig.json
tsconfig.test.json
tslint.example.json
tslint.json
tslint.test.json
webpack.config.js
Expand All @@ -30,4 +34,7 @@ yarn.lock
.npmignore
.prettierrc
.publishrc
.travis.yml
.travis.yml
.DS_Store
.AppleDouble
.LSOverride
32 changes: 20 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# RobotlegsJS Phaser Changelog:

## RobotlegsJS Phaser 0.1.0
## RobotlegsJS Phaser 0.2.0

### v0.1.0
### v0.2.0

- Update @robotlegsjs/core to version 0.2.0 (see #51).
Major Breaking Changes:
---

- Update phaser-ce to version 2.11.0 (see #46).
- Implement support for [phaser](https://github.com/photonstorm/phaser) plugin version 3. Suppor for [phaser-ce](https://github.com/photonstorm/phaser-ce) plugin was moved to [RobotlegsJS-Phaser-CE](https://github.com/RobotlegsJS/RobotlegsJS-Phaser-CE) (see #52).

- Remove eventemitter3 dependency (see #45).
- Move `phaser` library to **peerDependencies**, allowing the final user to choose the desired version of the [phaser](https://github.com/photonstorm/phaser) library on each project (see #52).

- Update `@robotlegsjs/core` to version `0.2.0` (see #51).

- Remove `eventemitter3` dependency (see #45).

Features Or Improvements:
---

- Add changelog (see #35).

Expand Down Expand Up @@ -38,19 +46,19 @@

### [v0.0.5](https://github.com/RobotlegsJS/RobotlegsJS-Phaser/releases/tag/0.0.5) - 2017-09-26

- Update @robotlegsjs/core to version 0.0.6 (see #9).
- Update `@robotlegsjs/core` to version `0.0.6` (see #9).

- Update phaser-ce to version 2.8.8 (see #10).
- Update `phaser-ce` to version `2.8.8` (see #10).

- Adapt to NPM [v5.0.0](http://blog.npmjs.org/post/161081169345/v500) (see #7).

- Update dev dependencies to latest version.

### [v0.0.4](https://github.com/RobotlegsJS/RobotlegsJS-Phaser/releases/tag/0.0.4) - 2017-09-15

- Update @robotlegsjs/core to version 0.0.5 (see #5).
- Update `@robotlegsjs/core` to version `0.0.5` (see #5).

- Update phaser-ce to version 2.8.7 (see #6).
- Update `phaser-ce` to version `2.8.7` (see #6).

- Update TSLint rules (see #6).

Expand All @@ -62,17 +70,17 @@

### [v0.0.3](https://github.com/RobotlegsJS/RobotlegsJS-Phaser/releases/tag/0.0.3) - 2017-08-30

- Update @robotlegsjs/core to version 0.0.4 (see #4).
- Update `@robotlegsjs/core` to version `0.0.4` (see #4).

- Update phaser-ce to version 2.8.4.
- Update `phaser-ce` to version `2.8.4`.

- Enable GreenKeeper.

- Update dev dependencies to latest version.

### [v0.0.2](https://github.com/RobotlegsJS/RobotlegsJS-Phaser/releases/tag/0.0.2) - 2017-08-12

- Update @robotlegsjs/core to version 0.0.3.
- Update `@robotlegsjs/core` to version `0.0.3`.

- Update contributing guidelines.

Expand Down
127 changes: 95 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
RobotlegsJS Phaser Extension
===
# RobotlegsJS Phaser Extension

[![GitHub license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobotlegsJS/RobotlegsJS-Phaser/blob/master/LICENSE)
[![Gitter chat](https://badges.gitter.im/RobotlegsJS/RobotlegsJS.svg)](https://gitter.im/RobotlegsJS/RobotlegsJS)
Expand All @@ -12,61 +11,125 @@ RobotlegsJS Phaser Extension
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

Integrate [RobotlegsJS](https://github.com/RobotlegsJS/RobotlegsJS)
framework with [Phaser](http://phaser.io).
framework with [Phaser](https://github.com/photonstorm/phaser).

Usage
---
## Installation

You can get the latest release and the type definitions using [NPM](https://www.npmjs.com/):

```bash
npm install @robotlegsjs/phaser --save-prod
```

Or using [Yarn](https://yarnpkg.com/en/):

```bash
yarn add @robotlegsjs/phaser
```

From version `0.2.0` of this package, the [Phaser](https://github.com/photonstorm/phaser) dependency was moved to **peerDependencies**,
allowing the final user to choose the desired version of the `phaser` library on each project.

The `@robotlegsjs/phaser` package is compatible with versions between the `>=3.11.0 <4` version range of `phaser` library.

As example, when you would like to use the version `3.11.0` of `phaser` library, you can run:

```bash
npm install [email protected] reflect-metadata --save-prod
```

or

```bash
yarn add [email protected] reflect-metadata
```

Then follow the [installation instructions](https://github.com/RobotlegsJS/RobotlegsJS/blob/master/README.md#installation) of **RobotlegsJS** library to complete the setup of your project.

**Dependencies**

+ [RobotlegsJS](https://github.com/RobotlegsJS/RobotlegsJS)
+ [tslib](https://github.com/Microsoft/tslib)

**Peer Dependencies**

+ [Phaser](https://github.com/photonstorm/phaser)
+ [reflect-metadata](https://github.com/rbuckton/reflect-metadata)

## Usage

```ts
/// <reference path="../node_modules/phaser-ce/typescript/phaser.d.ts" />
/// <reference path="../node_modules/@robotlegsjs/phaser/definitions/phaser.d.ts" />

import "reflect-metadata";
import * as Phaser from "phaser";

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

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 { ContextSceneManager } from "../src/robotlegs/bender/extensions/contextSceneManager/impl/ContextSceneManager";
import { PhaserBundle } from "../src/robotlegs/bender/bundles/phaser/PhaserBundle";

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

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

class Game extends Phaser.Game {
import { Boot } from "./scenes/Boot";
import { Main } from "./scenes/Main";
import { Preload } from "./scenes/Preload";

export class Game extends Phaser.Game {
private _context: IContext;

constructor() {

super(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.AUTO);
super({
type: Phaser.CANVAS,
width: 800,
height: 600,
backgroundColor: "#010101",
parent: "phaser-example"
});

this._context = new Context();
this._context.install(MVCSBundle, PhaserBundle)
.configure(new ContextStateManager(this.state))
.configure(StateMediatorConfig)
this._context
.install(MVCSBundle, PhaserBundle)
.configure(new ContextSceneManager(this.scene))
.configure(SceneMediatorConfig)
.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.scene.add(SceneKey.BOOT, new Boot());
this.scene.add(SceneKey.PRELOAD, new Preload());
this.scene.add(SceneKey.MAIN, new Main());

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

new Game();
```

[See example](example)

License
---
## Running the example

Run the following commands to run the example:

```bash
npm install
npm start
```

or:

```bash
yarn install
yarn start
```

## RobotlegsJS integration with Phaser CE (Community Edition)

The `@robotlegsjs/phaser` package was updated to support [Phaser v3](https://www.npmjs.com/package/phaser) plugin.

If you are looking for integration with [Phaser CE](https://github.com/photonstorm/phaser-ce) you can use the [RobotlegsJS-Phaser-CE](https://github.com/RobotlegsJS/RobotlegsJS-Phaser-CE) plugin.

## License

[MIT](LICENSE)
Loading

0 comments on commit 0a014fc

Please sign in to comment.