JSPM

@nativescript/canvas-phaser

1.0.0-beta.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q88186F
  • License Apache-2.0

Build awesome 2D games with Phaser.js and NativeScript

Package Exports

  • @nativescript/canvas-phaser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nativescript/canvas-phaser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@nativescript/canvas-phaser

Tools for using Phaser3 to build native 2D games in NativeScript πŸ‘ΎπŸ‘Ύ

Installation

npm i @nativescript/canvas-phaser

Usage

Import the library into your JavaScript file:

import TNSPhaser from "@nativescript/canvas-phaser";

Functions

TNSPhaser.game({ canvas, renderer: Phaser.WEBGL || Phaser.CANVAS, ...extras })

Given a canvas from a Canvas, return a Phaser.Game that draws into it.

Props

Property Type Description Default Value
canvas TNSCanvas Required: canvas that the Phaser.Game will render to null
renderer number? Optional: choose the renderer type e.g Phaser.CANVAS (1) , Phaser.WEBGL(2) 1
width number? Optional: height of the Phaser.Game canvas height
height number? Optional: width of the Phaser.Game canvas width
title string? Optional: title of the Phaser.Game "tns-phaser-game"

Returns

Property Type Description
game Phaser.Game The Phaser3 game used for rendering game logic

Example

const game = TNSPhaser.game({ canvas });

What does it do?

Under the hood, TNSPhaser is maintaining global instances of a few libraries.

window.Phaser = require("phaser");

Finally when a new instance of TNSPhaser.Game is created, we set the document.readyState to 'complete'

global.document.readyState = "complete";

License

Apache License Version 2.0, January 2004