Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @robotlegsjs/openfl with all npm packages installed. Try it out:

require("openfl/package.json"); // openfl is a peer dependency. require("reflect-metadata/package.json"); // reflect-metadata is a peer dependency. var openfl = require("@robotlegsjs/openfl")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@robotlegsjs/openfl v1.0.0

OpenFL View Integration with RobotlegsJS

RobotlegsJS OpenFL Extension

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

Integrate RobotlegsJS framework with OpenFL.

Installation

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

npm install @robotlegsjs/openfl --save

Or using Yarn:

yarn add @robotlegsjs/openfl

The OpenFL dependency is added as peerDependencies, allowing the final user to choose the desired version of the openfl library on each project.

The @robotlegsjs/openfl package is compatible with versions between the >=8.3.0 version range of openfl library.

As example, when you would like to use the version 8.3.0 of openfl library, you can run:

npm install openfl@8.3.0 reflect-metadata --save

or

yarn add openfl@8.3.0 reflect-metadata

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

Dependencies

Peer Dependencies

Usage

import "reflect-metadata";

import { Context, MVCSBundle } from "@robotlegsjs/core";

import { ContextView, OpenFLBundle } from "@robotlegsjs/openfl";

import { MyConfig } from "./config/MyConfig";

import { GameView } from "./view/GameView";

import Stage from "openfl/display/Stage";

export class Game {
    private _loading: HTMLDivElement;
    private _canvas: HTMLDivElement;

    private _stage: Stage;

    private _context: Context;

    constructor() {
        this.init();
    }

    private init(): void {
        // remove loader
        this._loading = <HTMLDivElement>(document.getElementById("loading"));
        document.body.removeChild(this._loading);

        // create stage
        this._stage = new Stage(960, 400, 0xffffff, GameView);

        // create robotlegs context
        this._context = new Context();
        this._context.install(MVCSBundle, OpenFLBundle).
            configure(new ContextView(this._stage)).
            configure(MyConfig).
            initialize();

        // add stage to html body
        this._canvas = <HTMLDivElement>(document.getElementById("canvas"));
        this._canvas.appendChild(this._stage.element);
    }
}

See full example here

Running the example

Run the following commands to run the example:

npm install
npm start

or:

yarn install
yarn start

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free