🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more
Socket
Book a DemoInstallSign in
Socket

@nativescript/canvas-phaser

Package Overview
Dependencies
Maintainers
18
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nativescript/canvas-phaser

Build awesome 2D games with Phaser.js and NativeScript

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
16
433.33%
Maintainers
18
Weekly downloads
 
Created
Source

@nativescript/canvas-phaser

Tools for using Phaser3 to build native 2D games in NativeScript 👾👾

  • Installation
  • Usage
  • Functions

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

PropertyTypeDescriptionDefault Value
canvasTNSCanvasRequired: canvas that the Phaser.Game will render tonull
renderernumber?Optional: choose the renderer type e.g Phaser.CANVAS (1) , Phaser.WEBGL(2)1
widthnumber?Optional: height of the Phaser.Gamecanvas height
heightnumber?Optional: width of the Phaser.Gamecanvas width
titlestring?Optional: title of the Phaser.Game"tns-phaser-game"

Returns

PropertyTypeDescription
gamePhaser.GameThe 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

Keywords

NativeScript

FAQs

Package last updated on 09 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts