@nativescript/canvas-phaser 2.0.12 β 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -60
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/game.d.ts +0 -1
- package/game.js +0 -64
- package/game.js.map +0 -1
- package/phaser.d.ts +0 -3
- package/phaser.js +0 -15
- package/phaser.js.map +0 -1
- package/tns-phaser.d.ts +0 -2
- package/tns-phaser.js +0 -3
- package/tns-phaser.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
# @nativescript/canvas-phaser
|
|
2
2
|
|
|
3
|
-
Tools for using
|
|
4
|
-
|
|
5
|
-
- [Installation](#installation)
|
|
6
|
-
- [Usage](#usage)
|
|
7
|
-
- [Functions](#functions)
|
|
3
|
+
Tools for using Phaser to build native 2D games in NativeScript πΎπΎ
|
|
8
4
|
|
|
9
5
|
### Installation
|
|
10
6
|
|
|
@@ -12,61 +8,6 @@ Tools for using Phaser3 to build native 2D games in NativeScript πΎπΎ
|
|
|
12
8
|
npm i @nativescript/canvas-phaser
|
|
13
9
|
```
|
|
14
10
|
|
|
15
|
-
### Usage
|
|
16
|
-
|
|
17
|
-
Import the library into your JavaScript file:
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
import TNSPhaser from "@nativescript/canvas-phaser";
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Functions
|
|
24
|
-
|
|
25
|
-
### `TNSPhaser.game({ canvas, renderer: Phaser.WEBGL || Phaser.CANVAS, ...extras })`
|
|
26
|
-
|
|
27
|
-
Given a `canvas` from a
|
|
28
|
-
[`Canvas`](https://github.com/nativescript/canvas), return a
|
|
29
|
-
[`Phaser.Game`](https://photonstorm.github.io/phaser3-docs/Phaser.Game.html)
|
|
30
|
-
that draws into it.
|
|
31
|
-
|
|
32
|
-
#### Props
|
|
33
|
-
|
|
34
|
-
| Property | Type | Description | Default Value |
|
|
35
|
-
| ----------- | :-------------------: | --------------------------------------------------------------------------- | :---------------------------: |
|
|
36
|
-
| canvas | TNSCanvas| Required: canvas that the `Phaser.Game` will render to | `null` |
|
|
37
|
-
| renderer | number?| Optional: choose the renderer type e.g Phaser.CANVAS (1) , Phaser.WEBGL(2) | `1` |
|
|
38
|
-
| width | number? | Optional: height of the `Phaser.Game` | `canvas height` |
|
|
39
|
-
| height | number? | Optional: width of the `Phaser.Game` | `canvas width` |
|
|
40
|
-
| title | string? | Optional: title of the `Phaser.Game` | `"tns-phaser-game"` |
|
|
41
|
-
|
|
42
|
-
#### Returns
|
|
43
|
-
|
|
44
|
-
| Property | Type | Description |
|
|
45
|
-
| -------- | :------------------------------------------------------------: | ------------------------------------------------ |
|
|
46
|
-
| game | [`Phaser.Game`](https://photonstorm.github.io/phaser3-docs/Phaser.Game.html) | The Phaser3 game used for rendering game logic |
|
|
47
|
-
|
|
48
|
-
## Example
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
const game = TNSPhaser.game({ canvas });
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## What does it do?
|
|
55
|
-
|
|
56
|
-
Under the hood, TNSPhaser is maintaining global instances of a few libraries.
|
|
57
|
-
|
|
58
|
-
- [Phaser3](https://github.com/photonstorm/phaser)
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
window.Phaser = require("phaser");
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Finally when a new instance of `TNSPhaser.Game` is created, we set the `document.readyState` to `'complete'`
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
global.document.readyState = "complete";
|
|
68
|
-
```
|
|
69
|
-
|
|
70
11
|
## License
|
|
71
12
|
|
|
72
13
|
Apache License Version 2.0, January 2004
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import '@nativescript/canvas-polyfill';
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import '@nativescript/canvas-polyfill';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/canvas-phaser/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/canvas-phaser/index.ts"],"names":[],"mappings":"AAAA,OAAO,+BAA+B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativescript/canvas-phaser",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
4
4
|
"description": "Build awesome 2D games with Phaser.js and NativeScript",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"bootstrapper": "@nativescript/plugin-seed",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@nativescript/canvas-polyfill": "*",
|
|
37
|
-
"phaser": "~
|
|
37
|
+
"phaser": "~4.0.0"
|
|
38
38
|
},
|
|
39
39
|
"types": "./index.d.ts"
|
|
40
40
|
}
|
package/game.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Game: (options: any) => any;
|
package/game.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import Phaser from './phaser';
|
|
2
|
-
export const Game = (options) => {
|
|
3
|
-
const title = options.title || 'tns-phaser-game';
|
|
4
|
-
// CANVAS
|
|
5
|
-
const AUTO = 0;
|
|
6
|
-
const CANVAS = 1;
|
|
7
|
-
const WEBGL = 2;
|
|
8
|
-
const type = options.type || WEBGL;
|
|
9
|
-
const customEnvironment = true;
|
|
10
|
-
const domCreateContainer = false;
|
|
11
|
-
const current = options;
|
|
12
|
-
const scene = options.scene || null;
|
|
13
|
-
const antialias = options.antialias || true;
|
|
14
|
-
const transparent = options.transparent || false;
|
|
15
|
-
const physics = options.physics || null;
|
|
16
|
-
const preventLoop = options.preventLoop;
|
|
17
|
-
const onRender = options.onRender;
|
|
18
|
-
const canvas = options.canvas;
|
|
19
|
-
let context;
|
|
20
|
-
let is2D = false;
|
|
21
|
-
switch (type) {
|
|
22
|
-
case 2:
|
|
23
|
-
context = canvas.getContext('webgl');
|
|
24
|
-
is2D = false;
|
|
25
|
-
break;
|
|
26
|
-
default:
|
|
27
|
-
context = canvas.getContext('2d');
|
|
28
|
-
is2D = true;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
global.document.readyState = 'complete';
|
|
32
|
-
let width;
|
|
33
|
-
let height;
|
|
34
|
-
width = options.width || canvas.width;
|
|
35
|
-
height = options.height || canvas.height;
|
|
36
|
-
delete current.domCreateContainer;
|
|
37
|
-
delete current.customEnvironment;
|
|
38
|
-
let config = {
|
|
39
|
-
width,
|
|
40
|
-
height,
|
|
41
|
-
//canvas,
|
|
42
|
-
context,
|
|
43
|
-
title,
|
|
44
|
-
type,
|
|
45
|
-
scene,
|
|
46
|
-
antialias,
|
|
47
|
-
transparent,
|
|
48
|
-
physics,
|
|
49
|
-
customEnvironment,
|
|
50
|
-
};
|
|
51
|
-
config = Object.assign(config, current);
|
|
52
|
-
const game = new Phaser.Game(config);
|
|
53
|
-
game.width = width;
|
|
54
|
-
game.height = height;
|
|
55
|
-
const render = function () {
|
|
56
|
-
requestAnimationFrame(render);
|
|
57
|
-
onRender && onRender();
|
|
58
|
-
};
|
|
59
|
-
if (!preventLoop) {
|
|
60
|
-
render();
|
|
61
|
-
}
|
|
62
|
-
return game;
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=game.js.map
|
package/game.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"game.js","sourceRoot":"","sources":["../../../packages/canvas-phaser/game.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAA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AAI,MAAM,CAAC;IAEX,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;IACtC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC;IAGzC,OAAO,OAAO,CAAC,kBAAkB,CAAC;IAClC,OAAO,OAAO,CAAC,iBAAiB,CAAC;IAEjC,IAAI,MAAM,GAAG;QACZ,KAAK;QACL,MAAM;QACN,SAAS;QACT,OAAO;QACP,KAAK;QACL,IAAI;QACJ,KAAK;QACL,SAAS;QACT,WAAW;QACX,OAAO;QACP,iBAAiB;KACjB,CAAC;IAGF,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,MAAM,GAAG;QACd,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC9B,QAAQ,IAAI,QAAQ,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,MAAM,EAAE,CAAC;IACV,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAA"}
|
package/phaser.d.ts
DELETED
package/phaser.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import '@nativescript/canvas-polyfill';
|
|
2
|
-
function initPhaser() {
|
|
3
|
-
/* if ((global as any).Phaser) {
|
|
4
|
-
const version = parseFloat((global as any).Phaser.VERSION);
|
|
5
|
-
if (!Number.isNaN(version) && version < 3) {
|
|
6
|
-
(global as any).PIXI = (global as any).window.PIXI = undefined;
|
|
7
|
-
(global as any).p2 = (global as any).window.p2 = undefined;
|
|
8
|
-
(global as any).window.Phaser = (global as any).Phaser = undefined;
|
|
9
|
-
}
|
|
10
|
-
}*/
|
|
11
|
-
global.window.Phaser = global.Phaser = global.Phaser || require('phaser');
|
|
12
|
-
return global.Phaser;
|
|
13
|
-
}
|
|
14
|
-
export default initPhaser();
|
|
15
|
-
//# sourceMappingURL=phaser.js.map
|
package/phaser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"phaser.js","sourceRoot":"","sources":["../../../packages/canvas-phaser/phaser.ts"],"names":[],"mappings":"AAAA,OAAO,+BAA+B,CAAC;AAEvC,SAAS,UAAU;IAClB;;;;;;;KAOI;IACH,MAAc,CAAC,MAAM,CAAC,MAAM,GAAI,MAAc,CAAC,MAAM,GAAI,MAAc,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrG,OAAQ,MAAc,CAAC,MAAM,CAAC;AAC/B,CAAC;AAED,eAAe,UAAU,EAAE,CAAC"}
|
package/tns-phaser.d.ts
DELETED
package/tns-phaser.js
DELETED
package/tns-phaser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tns-phaser.js","sourceRoot":"","sources":["../../../packages/canvas-phaser/tns-phaser.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|