@safe-engine/pixi 8.3.7 → 8.4.1
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/.github/workflows/npm-publish.yml +35 -0
- package/README.md +70 -5
- package/dist/app.d.ts +2 -5
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +44 -27
- package/dist/base/gworld.d.ts +2 -0
- package/dist/base/gworld.d.ts.map +1 -1
- package/dist/box2d-wasm/ContactListener.d.ts +12 -0
- package/dist/box2d-wasm/ContactListener.d.ts.map +1 -0
- package/dist/box2d-wasm/ContactListener.js +64 -0
- package/dist/box2d-wasm/PhysicsComponent.d.ts +50 -0
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsComponent.js +17 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts +11 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSprite.js +30 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts +17 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSystem.js +145 -0
- package/dist/box2d-wasm/debugDraw.d.ts +67 -0
- package/dist/box2d-wasm/debugDraw.d.ts.map +1 -0
- package/dist/box2d-wasm/debugDraw.js +224 -0
- package/dist/box2d-wasm/index.d.ts +6 -0
- package/dist/box2d-wasm/index.d.ts.map +1 -0
- package/dist/box2d-wasm/index.js +17 -0
- package/dist/collider/CollideComponent.d.ts.map +1 -1
- package/dist/collider/CollideComponent.js +12 -13
- package/dist/collider/CollideSystem.d.ts.map +1 -1
- package/dist/collider/CollideSystem.js +1 -2
- package/dist/collider/helper/utils.d.ts +2 -0
- package/dist/collider/helper/utils.d.ts.map +1 -1
- package/dist/collider/helper/utils.js +22 -0
- package/dist/collider/index.d.ts +1 -0
- package/dist/collider/index.d.ts.map +1 -1
- package/dist/collider/index.js +12 -0
- package/dist/components/NodeComp.d.ts +6 -4
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +13 -13
- package/dist/components/Scene.d.ts.map +1 -1
- package/dist/components/Scene.js +3 -4
- package/dist/core/director.d.ts.map +1 -1
- package/dist/core/director.js +4 -3
- package/dist/dragonbones/DragonBonesSystem.d.ts +2 -1
- package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesSystem.js +2 -0
- package/dist/dragonbones/index.d.ts +1 -0
- package/dist/dragonbones/index.d.ts.map +1 -1
- package/dist/dragonbones/index.js +7 -0
- package/dist/gui/GUIComponent.d.ts +0 -9
- package/dist/gui/GUIComponent.d.ts.map +1 -1
- package/dist/gui/GUIComponent.js +0 -37
- package/dist/gui/GUISystem.d.ts +1 -0
- package/dist/gui/GUISystem.d.ts.map +1 -1
- package/dist/gui/GUISystem.js +2 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/planck/PhysicsComponent.d.ts +7 -7
- package/dist/planck/PhysicsComponent.js +4 -4
- package/dist/planck/PhysicsSystem.js +12 -12
- package/dist/richtext/RichTextComp.d.ts +17 -0
- package/dist/richtext/RichTextComp.d.ts.map +1 -0
- package/dist/richtext/RichTextComp.js +38 -0
- package/dist/richtext/RichTextSystem.d.ts +7 -0
- package/dist/richtext/RichTextSystem.d.ts.map +1 -0
- package/dist/richtext/RichTextSystem.js +25 -0
- package/dist/richtext/html-text-parser.d.ts +20 -0
- package/dist/richtext/html-text-parser.d.ts.map +1 -0
- package/dist/richtext/html-text-parser.js +64 -0
- package/dist/richtext/index.d.ts +3 -0
- package/dist/richtext/index.d.ts.map +1 -0
- package/dist/richtext/index.js +7 -0
- package/dist/spine/index.d.ts +1 -0
- package/dist/spine/index.d.ts.map +1 -1
- package/dist/spine/index.js +7 -0
- package/package.json +9 -11
- package/src/@types/index.d.ts +2 -0
- package/src/@types/safex.d.ts +15 -0
- package/src/app.ts +85 -0
- package/src/base/EnhancedComponent.ts +37 -0
- package/src/base/gworld.ts +19 -0
- package/src/base/index.ts +3 -0
- package/src/base/utils.ts +23 -0
- package/src/box2d-wasm/ContactListener.ts +66 -0
- package/src/box2d-wasm/PhysicsComponent.ts +83 -0
- package/src/box2d-wasm/PhysicsSprite.ts +42 -0
- package/src/box2d-wasm/PhysicsSystem.ts +145 -0
- package/src/box2d-wasm/debugDraw.ts +257 -0
- package/src/box2d-wasm/index.ts +19 -0
- package/src/collider/CollideComponent.ts +257 -0
- package/src/collider/CollideSystem.ts +166 -0
- package/src/collider/helper/Intersection.ts +139 -0
- package/src/collider/helper/utils.ts +37 -0
- package/src/collider/index.ts +16 -0
- package/src/components/BaseComponent.ts +17 -0
- package/src/components/NodeComp.ts +434 -0
- package/src/components/Scene.ts +17 -0
- package/src/core/Color.ts +7 -0
- package/src/core/LoadingBar.ts +63 -0
- package/src/core/NodePool.ts +28 -0
- package/src/core/Size.ts +21 -0
- package/src/core/director.ts +11 -0
- package/src/core/math.ts +13 -0
- package/src/dragonbones/DragonBonesComponent.ts +32 -0
- package/src/dragonbones/DragonBonesSystem.ts +35 -0
- package/src/dragonbones/index.ts +11 -0
- package/src/gui/GUIComponent.ts +159 -0
- package/src/gui/GUISystem.ts +116 -0
- package/src/helper/utils.ts +50 -0
- package/src/index.ts +23 -0
- package/src/norender/NoRenderComponent.ts +60 -0
- package/src/norender/NoRenderSystem.ts +66 -0
- package/src/planck/PhysicsComponent.ts +83 -0
- package/src/planck/PhysicsSprite.ts +43 -0
- package/src/planck/PhysicsSystem.ts +201 -0
- package/src/planck/index.ts +3 -0
- package/src/render/RenderComponent.ts +138 -0
- package/src/render/RenderSystem.ts +67 -0
- package/src/richtext/RichTextComp.ts +46 -0
- package/src/richtext/RichTextSystem.ts +26 -0
- package/src/richtext/html-text-parser.ts +87 -0
- package/src/richtext/index.ts +8 -0
- package/src/spine/SpineComponent.ts +18 -0
- package/src/spine/SpineSystem.ts +30 -0
- package/src/spine/index.ts +11 -0
- package/src/spine/lib/BatchableSpineSlot.ts +138 -0
- package/src/spine/lib/Spine.ts +910 -0
- package/src/spine/lib/SpineDebugRenderer.ts +615 -0
- package/src/spine/lib/SpinePipe.ts +203 -0
- package/src/spine/lib/SpineTexture.ts +143 -0
- package/src/spine/lib/assets/atlasLoader.ts +158 -0
- package/src/spine/lib/assets/skeletonLoader.ts +81 -0
- package/src/spine/lib/darktint/DarkTintBatchGeometry.ts +92 -0
- package/src/spine/lib/darktint/DarkTintBatcher.ts +186 -0
- package/src/spine/lib/darktint/DarkTintShader.ts +74 -0
- package/src/spine/lib/darktint/darkTintBit.ts +77 -0
- package/src/spine/lib/index.ts +43 -0
- package/src/spine/lib/require-shim.ts +43 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Graphics } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Forked from Box2D.js
|
|
4
|
+
* @see https://github.com/kripken/box2d.js/blob/f75077b/helpers/embox2d-helpers.js
|
|
5
|
+
* @author dmagunov + Huy Nguyen + fork contributions from Alex Birch
|
|
6
|
+
* @see https://github.com/kripken/box2d.js/blob/49dddd6/helpers/embox2d-html5canvas-debugDraw.js
|
|
7
|
+
* @author dmagunov + fork contributions from Alex Birch
|
|
8
|
+
* @license Zlib https://opensource.org/licenses/Zlib
|
|
9
|
+
* License evidence: https://github.com/kripken/box2d.js/blob/master/README.markdown#box2djs
|
|
10
|
+
* "box2d.js is zlib licensed, just like Box2D."
|
|
11
|
+
*
|
|
12
|
+
* @typedef {import('box2d-wasm')} Box2DFactory
|
|
13
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
14
|
+
* @param {number} pixelsPerMeter
|
|
15
|
+
* @param {typeof Box2D & EmscriptenModule} box2D
|
|
16
|
+
*/
|
|
17
|
+
export declare const makeDebugDraw: (graphics: Graphics, pixelsPerMeter: any, box2D: typeof Box2D) => Box2D.JSDraw & {
|
|
18
|
+
/**
|
|
19
|
+
* @param {number} vert1_p pointer to {@link Box2D.b2Vec2}
|
|
20
|
+
* @param {number} vert2_p pointer to {@link Box2D.b2Vec2}
|
|
21
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
DrawSegment(vert1_p: any, vert2_p: any, color_p: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* @param {number} vertices_p pointer to Array<{@link Box2D.b2Vec2}>
|
|
27
|
+
* @param {number} vertexCount
|
|
28
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
DrawPolygon(vertices_p: any, vertexCount: any, color_p: any): void;
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} vertices_p pointer to Array<{@link Box2D.b2Vec2}>
|
|
34
|
+
* @param {number} vertexCount
|
|
35
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
DrawSolidPolygon(vertices_p: any, vertexCount: any, color_p: any): void;
|
|
39
|
+
/**
|
|
40
|
+
* @param {number} center_p pointer to {@link Box2D.b2Vec2}
|
|
41
|
+
* @param {number} radius
|
|
42
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
DrawCircle(center_p: any, radius: any, color_p: any): void;
|
|
46
|
+
/**
|
|
47
|
+
* @param {number} center_p pointer to {@link Box2D.b2Vec2}
|
|
48
|
+
* @param {number} radius
|
|
49
|
+
* @param {number} axis_p pointer to {@link Box2D.b2Vec2}
|
|
50
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
DrawSolidCircle(center_p: any, radius: any, axis_p: any, color_p: any): void;
|
|
54
|
+
/**
|
|
55
|
+
* @param {number} transform_p pointer to {@link Box2D.b2Transform}
|
|
56
|
+
* @returns {void}
|
|
57
|
+
*/
|
|
58
|
+
DrawTransform(transform_p: any): void;
|
|
59
|
+
/**
|
|
60
|
+
* @param {number} vertex_p pointer to {@link Box2D.b2Vec2}
|
|
61
|
+
* @param {number} sizeMetres
|
|
62
|
+
* @param {number} pointer to {@link Box2D.b2Color}
|
|
63
|
+
* @returns {void}
|
|
64
|
+
*/
|
|
65
|
+
DrawPoint(vertex_p: any, sizeMetres: any, color_p: any): void;
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=debugDraw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugDraw.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/debugDraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,QAAQ,EAAE,mBAAc,EAAE,OAAO,OAAO,KAAK;IAuJjF;;;;;OAKG;;IAQH;;;;;OAKG;;IAQH;;;;;OAKG;;IAOH;;;;;OAKG;;IAQH;;;;;;OAMG;;IAQH;;;OAGG;;IAKH;;;;;OAKG;;CAUN,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { Color4B } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Forked from Box2D.js
|
|
4
|
+
* @see https://github.com/kripken/box2d.js/blob/f75077b/helpers/embox2d-helpers.js
|
|
5
|
+
* @author dmagunov + Huy Nguyen + fork contributions from Alex Birch
|
|
6
|
+
* @see https://github.com/kripken/box2d.js/blob/49dddd6/helpers/embox2d-html5canvas-debugDraw.js
|
|
7
|
+
* @author dmagunov + fork contributions from Alex Birch
|
|
8
|
+
* @license Zlib https://opensource.org/licenses/Zlib
|
|
9
|
+
* License evidence: https://github.com/kripken/box2d.js/blob/master/README.markdown#box2djs
|
|
10
|
+
* "box2d.js is zlib licensed, just like Box2D."
|
|
11
|
+
*
|
|
12
|
+
* @typedef {import('box2d-wasm')} Box2DFactory
|
|
13
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
14
|
+
* @param {number} pixelsPerMeter
|
|
15
|
+
* @param {typeof Box2D & EmscriptenModule} box2D
|
|
16
|
+
*/
|
|
17
|
+
export const makeDebugDraw = (graphics, pixelsPerMeter, box2D) => {
|
|
18
|
+
const { b2Color, b2Draw: { e_shapeBit }, b2Transform, b2Vec2, JSDraw, wrapPointer } = box2D;
|
|
19
|
+
/**
|
|
20
|
+
* to replace original C++ operator =
|
|
21
|
+
* @param {Box2D.b2Vec2} vec
|
|
22
|
+
* @returns {Box2D.b2Vec2}
|
|
23
|
+
*/
|
|
24
|
+
const copyVec2 = (vec) => new b2Vec2(vec.get_x(), vec.get_y());
|
|
25
|
+
/**
|
|
26
|
+
* to replace original C++ operator *= (float)
|
|
27
|
+
* @param {Box2D.b2Vec2} vec
|
|
28
|
+
* @param {number} scale
|
|
29
|
+
* @returns {Box2D.b2Vec2}
|
|
30
|
+
*/
|
|
31
|
+
const scaledVec2 = (vec, scale) => new b2Vec2(scale * vec.get_x(), scale * vec.get_y());
|
|
32
|
+
/**
|
|
33
|
+
* @param {Box2D.b2Color} color
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
const getRgbStr = (color) => {
|
|
37
|
+
const red = (color.get_r() * 255) | 0;
|
|
38
|
+
const green = (color.get_g() * 255) | 0;
|
|
39
|
+
const blue = (color.get_b() * 255) | 0;
|
|
40
|
+
return Color4B(red, green, blue, 0.1);
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} rgbStr
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
const setCtxColor = (rgbStr) => {
|
|
47
|
+
graphics.fillStyle = rgbStr;
|
|
48
|
+
graphics.strokeStyle = { color: rgbStr };
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @param {Box2D.b2Vec2[]} vertices
|
|
52
|
+
* @param {boolean} fill
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
const drawPolygon = (vertices, fill) => {
|
|
56
|
+
// console.log("drawPolygon", vertices[0].y, fill);
|
|
57
|
+
// graphics.poly(vertices, fill)
|
|
58
|
+
graphics.moveTo(vertices[vertices.length - 1].x * pixelsPerMeter, vertices[vertices.length - 1].y * pixelsPerMeter);
|
|
59
|
+
vertices.forEach((v) => {
|
|
60
|
+
graphics.lineTo(v.x * pixelsPerMeter, v.y * pixelsPerMeter);
|
|
61
|
+
});
|
|
62
|
+
graphics.fill();
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* @param {Box2D.b2Vec2} center
|
|
66
|
+
* @param {number} radius
|
|
67
|
+
* @param {Box2D.b2Vec2} axis
|
|
68
|
+
* @param {boolean} fill
|
|
69
|
+
* @returns {void}
|
|
70
|
+
*/
|
|
71
|
+
const drawCircle = (center, radius, axis, fill) => {
|
|
72
|
+
// graphics.circle(center.x, center.y, radius)
|
|
73
|
+
let angle = 0;
|
|
74
|
+
const angleStep = 32;
|
|
75
|
+
const n = 360 / angleStep;
|
|
76
|
+
let x = radius * Math.cos(angle * Math.PI / 180);
|
|
77
|
+
let y = radius * Math.sin(angle * Math.PI / 180);
|
|
78
|
+
graphics.moveTo(center.x + x, center.y + y);
|
|
79
|
+
angle += angleStep;
|
|
80
|
+
for (let i = 0; i < n; i++) {
|
|
81
|
+
x = radius * Math.cos(angle * Math.PI / 180);
|
|
82
|
+
y = radius * Math.sin(angle * Math.PI / 180);
|
|
83
|
+
graphics.lineTo(center.x + x, center.y + y);
|
|
84
|
+
angle += angleStep;
|
|
85
|
+
}
|
|
86
|
+
graphics.fill();
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @param {Box2D.b2Vec2} vert1
|
|
90
|
+
* @param {Box2D.b2Vec2} vert2
|
|
91
|
+
* @returns {void}
|
|
92
|
+
*/
|
|
93
|
+
const drawSegment = (vert1, vert2) => {
|
|
94
|
+
// console.log("drawSegment", vert1, vert2)
|
|
95
|
+
graphics.moveTo(vert1.get_x(), vert1.get_y());
|
|
96
|
+
graphics.lineTo(vert2.get_x(), vert2.get_y());
|
|
97
|
+
graphics.stroke();
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @param {Box2D.b2Vec2} vertex
|
|
101
|
+
* @param {number} sizeMetres
|
|
102
|
+
* @returns {void}
|
|
103
|
+
*/
|
|
104
|
+
const drawPoint = (vertex, sizeMetres) => {
|
|
105
|
+
const sizePixels = sizeMetres / pixelsPerMeter;
|
|
106
|
+
graphics.rect(vertex.get_x() - sizePixels / 2, vertex.get_y() - sizePixels / 2, sizePixels, sizePixels);
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* @param {Box2D.b2Transform} transform
|
|
110
|
+
* @param {number} sizeMetres
|
|
111
|
+
* @returns {void}
|
|
112
|
+
*/
|
|
113
|
+
const drawTransform = (transform) => {
|
|
114
|
+
const pos = transform.get_p();
|
|
115
|
+
const rot = transform.get_q();
|
|
116
|
+
graphics.save();
|
|
117
|
+
graphics.translateTransform(pos.get_x(), pos.get_y());
|
|
118
|
+
graphics.scaleTransform(0.5, 0.5);
|
|
119
|
+
graphics.rotateTransform(rot.GetAngle());
|
|
120
|
+
// graphics.lineWidth *= 2;
|
|
121
|
+
graphics.restore();
|
|
122
|
+
};
|
|
123
|
+
/** {@link Box2D.b2Vec2} is a struct of `float x, y` */
|
|
124
|
+
const sizeOfB2Vec = Float32Array.BYTES_PER_ELEMENT * 2;
|
|
125
|
+
/**
|
|
126
|
+
* @param {number} array_p pointer to {@link Box2D.b2Vec2}
|
|
127
|
+
* @param {number} numElements length of array
|
|
128
|
+
* @param {number} sizeOfElement size of an instance of the array element
|
|
129
|
+
* @param {typeof Box2D.b2Vec2} ctor constructor for the array element
|
|
130
|
+
* @return {Box2D.b2Vec2[]}
|
|
131
|
+
*/
|
|
132
|
+
const reifyArray = (array_p, numElements, sizeOfElement, ctor) => Array(numElements)
|
|
133
|
+
.fill(undefined)
|
|
134
|
+
.map((_, index) => wrapPointer(array_p + index * sizeOfElement, ctor));
|
|
135
|
+
const debugDraw = Object.assign(new JSDraw(), {
|
|
136
|
+
/**
|
|
137
|
+
* @param {number} vert1_p pointer to {@link Box2D.b2Vec2}
|
|
138
|
+
* @param {number} vert2_p pointer to {@link Box2D.b2Vec2}
|
|
139
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
140
|
+
* @returns {void}
|
|
141
|
+
*/
|
|
142
|
+
DrawSegment(vert1_p, vert2_p, color_p) {
|
|
143
|
+
const color = wrapPointer(color_p, b2Color);
|
|
144
|
+
setCtxColor(getRgbStr(color));
|
|
145
|
+
const vert1 = wrapPointer(vert1_p, b2Vec2);
|
|
146
|
+
const vert2 = wrapPointer(vert2_p, b2Vec2);
|
|
147
|
+
drawSegment(vert1, vert2);
|
|
148
|
+
},
|
|
149
|
+
/**
|
|
150
|
+
* @param {number} vertices_p pointer to Array<{@link Box2D.b2Vec2}>
|
|
151
|
+
* @param {number} vertexCount
|
|
152
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
153
|
+
* @returns {void}
|
|
154
|
+
*/
|
|
155
|
+
DrawPolygon(vertices_p, vertexCount, color_p) {
|
|
156
|
+
const color = wrapPointer(color_p, b2Color);
|
|
157
|
+
setCtxColor(getRgbStr(color));
|
|
158
|
+
const vertices = reifyArray(vertices_p, vertexCount, sizeOfB2Vec, b2Vec2);
|
|
159
|
+
drawPolygon(vertices, false);
|
|
160
|
+
// console.log(`DrawPolygon`, getRgbStr(color).green, vertices[0].y)
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* @param {number} vertices_p pointer to Array<{@link Box2D.b2Vec2}>
|
|
164
|
+
* @param {number} vertexCount
|
|
165
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
166
|
+
* @returns {void}
|
|
167
|
+
*/
|
|
168
|
+
DrawSolidPolygon(vertices_p, vertexCount, color_p) {
|
|
169
|
+
const color = wrapPointer(color_p, b2Color);
|
|
170
|
+
setCtxColor(getRgbStr(color));
|
|
171
|
+
const vertices = reifyArray(vertices_p, vertexCount, sizeOfB2Vec, b2Vec2);
|
|
172
|
+
drawPolygon(vertices, true);
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* @param {number} center_p pointer to {@link Box2D.b2Vec2}
|
|
176
|
+
* @param {number} radius
|
|
177
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
178
|
+
* @returns {void}
|
|
179
|
+
*/
|
|
180
|
+
DrawCircle(center_p, radius, color_p) {
|
|
181
|
+
const color = wrapPointer(color_p, b2Color);
|
|
182
|
+
setCtxColor(getRgbStr(color));
|
|
183
|
+
const center = wrapPointer(center_p, b2Vec2);
|
|
184
|
+
const dummyAxis = new b2Vec2(0, 0);
|
|
185
|
+
drawCircle(center, radius, dummyAxis, false);
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* @param {number} center_p pointer to {@link Box2D.b2Vec2}
|
|
189
|
+
* @param {number} radius
|
|
190
|
+
* @param {number} axis_p pointer to {@link Box2D.b2Vec2}
|
|
191
|
+
* @param {number} color_p pointer to {@link Box2D.b2Color}
|
|
192
|
+
* @returns {void}
|
|
193
|
+
*/
|
|
194
|
+
DrawSolidCircle(center_p, radius, axis_p, color_p) {
|
|
195
|
+
const color = wrapPointer(color_p, b2Color);
|
|
196
|
+
setCtxColor(getRgbStr(color));
|
|
197
|
+
const center = wrapPointer(center_p, b2Vec2);
|
|
198
|
+
const axis = wrapPointer(axis_p, b2Vec2);
|
|
199
|
+
drawCircle(center, radius, axis, true);
|
|
200
|
+
},
|
|
201
|
+
/**
|
|
202
|
+
* @param {number} transform_p pointer to {@link Box2D.b2Transform}
|
|
203
|
+
* @returns {void}
|
|
204
|
+
*/
|
|
205
|
+
DrawTransform(transform_p) {
|
|
206
|
+
const transform = wrapPointer(transform_p, b2Transform);
|
|
207
|
+
drawTransform(transform);
|
|
208
|
+
},
|
|
209
|
+
/**
|
|
210
|
+
* @param {number} vertex_p pointer to {@link Box2D.b2Vec2}
|
|
211
|
+
* @param {number} sizeMetres
|
|
212
|
+
* @param {number} pointer to {@link Box2D.b2Color}
|
|
213
|
+
* @returns {void}
|
|
214
|
+
*/
|
|
215
|
+
DrawPoint(vertex_p, sizeMetres, color_p) {
|
|
216
|
+
const color = wrapPointer(color_p, b2Color);
|
|
217
|
+
setCtxColor(getRgbStr(color));
|
|
218
|
+
const vertex = wrapPointer(vertex_p, b2Vec2);
|
|
219
|
+
drawPoint(vertex, sizeMetres);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
debugDraw.SetFlags(e_shapeBit);
|
|
223
|
+
return debugDraw;
|
|
224
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GameWorld, Vec2 } from '..';
|
|
2
|
+
export * from './PhysicsComponent';
|
|
3
|
+
export * from './PhysicsSprite';
|
|
4
|
+
export * from './PhysicsSystem';
|
|
5
|
+
export declare function setupPhysics(world?: GameWorld, isDebugDraw?: boolean, gravity?: Vec2): void;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAGpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAE/B,wBAAgB,YAAY,CAAC,KAAK,YAAqB,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,IAAI,QAW7F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GameWorld } from '..';
|
|
2
|
+
import { PhysicsSystem } from './PhysicsSystem';
|
|
3
|
+
export * from './PhysicsComponent';
|
|
4
|
+
export * from './PhysicsSprite';
|
|
5
|
+
export * from './PhysicsSystem';
|
|
6
|
+
export function setupPhysics(world = GameWorld.Instance, isDebugDraw, gravity) {
|
|
7
|
+
console.log('app world', world.app);
|
|
8
|
+
world.systems.add(PhysicsSystem);
|
|
9
|
+
world.systems.configureOnce(PhysicsSystem);
|
|
10
|
+
world.listUpdate.push(PhysicsSystem);
|
|
11
|
+
if (isDebugDraw) {
|
|
12
|
+
world.systems.get(PhysicsSystem).addDebug();
|
|
13
|
+
}
|
|
14
|
+
if (gravity) {
|
|
15
|
+
world.systems.get(PhysicsSystem).gravity = gravity;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollideComponent.d.ts","sourceRoot":"","sources":["../../src/collider/CollideComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CollideComponent.d.ts","sourceRoot":"","sources":["../../src/collider/CollideComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAiBhE,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC5C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC3C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;CAC5C;AAED,qBAAa,QAAQ,CAAC,CAAC,GAAG,aAAa,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IACpE,YAAY,EAAE,KAAK,EAAE,CAAK;IAC1B,cAAc,EAAE,KAAK,CAAA;IACrB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,OAAO,CAAA;IACxB,gBAAgB,EAAE,OAAO,CAAA;gBAEb,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IAsBpD,WAAW;IAiBX,IAAI;CAyBL"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import max from 'lodash/max';
|
|
2
|
-
import min from 'lodash/min';
|
|
3
1
|
import { Rectangle } from 'pixi.js';
|
|
4
|
-
import {
|
|
2
|
+
import { GameWorld } from '..';
|
|
5
3
|
import { NoRenderComponentX } from '../components/BaseComponent';
|
|
6
4
|
import { v2 } from '../helper/utils';
|
|
7
5
|
import { circleCircle, polygonCircle, polygonPolygon } from './helper/Intersection';
|
|
6
|
+
import { getMax, getMin } from './helper/utils';
|
|
8
7
|
function getNodeToWorldTransformAR(node) {
|
|
9
8
|
const t = node.instance.worldTransform;
|
|
10
9
|
const x = node.instance.pivot.x * node.instance.width;
|
|
@@ -64,10 +63,10 @@ export class BoxCollider extends Collider {
|
|
|
64
63
|
const listX = collider._worldPoints.map(({ x }) => x);
|
|
65
64
|
const listY = collider._worldPoints.map(({ y }) => y);
|
|
66
65
|
collider._preAabb = cloneRect(collider._AABB);
|
|
67
|
-
collider._AABB.x =
|
|
68
|
-
collider._AABB.y =
|
|
69
|
-
collider._AABB.width =
|
|
70
|
-
collider._AABB.height =
|
|
66
|
+
collider._AABB.x = getMin(listX);
|
|
67
|
+
collider._AABB.y = getMin(listY);
|
|
68
|
+
collider._AABB.width = getMax(listX) - collider._AABB.x;
|
|
69
|
+
collider._AABB.height = getMax(listY) - collider._AABB.y;
|
|
71
70
|
if (draw) {
|
|
72
71
|
// console.log("drawing", JSON.stringify(collider._worldPoints))
|
|
73
72
|
const drawList = collider._worldPoints;
|
|
@@ -88,7 +87,7 @@ export class CircleCollider extends Collider {
|
|
|
88
87
|
collider._worldPosition = transform.apply(this.props.offset);
|
|
89
88
|
if (draw) {
|
|
90
89
|
const { x } = collider._worldPosition;
|
|
91
|
-
const y = app.screen.height - collider._worldPosition.y;
|
|
90
|
+
const y = GameWorld.Instance.app.screen.height - collider._worldPosition.y;
|
|
92
91
|
draw.rect(x, y, 2, 2);
|
|
93
92
|
draw.circle(x, y, collider._worldRadius);
|
|
94
93
|
}
|
|
@@ -120,16 +119,16 @@ export class PolygonCollider extends Collider {
|
|
|
120
119
|
collider._worldPoints = this.points.map((p) => transform.apply(p));
|
|
121
120
|
// log(polyPoints);
|
|
122
121
|
if (draw) {
|
|
123
|
-
const drawList = collider._worldPoints.map(({ x, y }) => v2(x, app.screen.height - y));
|
|
122
|
+
const drawList = collider._worldPoints.map(({ x, y }) => v2(x, GameWorld.Instance.app.screen.height - y));
|
|
124
123
|
draw.poly(drawList);
|
|
125
124
|
}
|
|
126
125
|
const listX = collider._worldPoints.map(({ x }) => x);
|
|
127
126
|
const listY = collider._worldPoints.map(({ y }) => y);
|
|
128
127
|
collider._preAabb = cloneRect(collider._AABB);
|
|
129
|
-
collider._AABB.x =
|
|
130
|
-
collider._AABB.y =
|
|
131
|
-
collider._AABB.width =
|
|
132
|
-
collider._AABB.height =
|
|
128
|
+
collider._AABB.x = getMin(listX);
|
|
129
|
+
collider._AABB.y = getMin(listY);
|
|
130
|
+
collider._AABB.width = getMax(listX) - collider._AABB.x;
|
|
131
|
+
collider._AABB.height = getMax(listY) - collider._AABB.y;
|
|
133
132
|
// draw.drawRect(p(this._AABB.x, this._AABB.y), p(max(listX), max(listY)),
|
|
134
133
|
// Color.WHITE, 3, Color.DEBUG_BORDER_COLOR);
|
|
135
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollideSystem.d.ts","sourceRoot":"","sources":["../../src/collider/CollideSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"CollideSystem.d.ts","sourceRoot":"","sources":["../../src/collider/CollideSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIzC,OAAO,EAA+B,QAAQ,EAAiB,QAAQ,EAAmB,MAAM,oBAAoB,CAAA;AAEpH,wBAAgB,gBAAgB,CAAC,MAAM,UAAO,QAG7C;AAED,qBAAa,aAAc,YAAW,MAAM;IAC1C,aAAa,EAAE,QAAQ,EAAE,CAAK;IAC9B,UAAU,EAAE,QAAQ,EAAE,CAAK;IAC3B,eAAe,EAAE,QAAQ,EAAE,CAAK;IAChC,aAAa,EAAE,QAAQ,CAAA;IACvB,gBAAgB,UAAO;IACvB,OAAO,UAAO;IACd,cAAc,cAAW;IAEzB,SAAS,CAAC,aAAa,EAAE,YAAY;IAgBrC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;IAwGhE,WAAW,CAAC,eAAe,EAAE,QAAQ;IASrC,cAAc,CAAC,eAAe,EAAE,QAAQ;IAGxC,aAAa,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE;;;KAAA;IAOnC,gBAAgB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE;;;KAAA;CAKvC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EventTypes } from 'entityx-ts';
|
|
2
2
|
import { Color, Graphics } from 'pixi.js';
|
|
3
|
-
import { app } from '../app';
|
|
4
3
|
import { GameWorld } from '../base';
|
|
5
4
|
import { NodeComp } from '../components/NodeComp';
|
|
6
5
|
import { BoxCollider, CircleCollider, Collider, CollisionType, Contract, PolygonCollider } from './CollideComponent';
|
|
@@ -30,7 +29,7 @@ export class CollideSystem {
|
|
|
30
29
|
this.debugGraphics.width = 4;
|
|
31
30
|
this.debugGraphics.zIndex = 40;
|
|
32
31
|
}
|
|
33
|
-
app.stage.addChild(this.debugGraphics);
|
|
32
|
+
GameWorld.Instance.app.stage.addChild(this.debugGraphics);
|
|
34
33
|
}
|
|
35
34
|
update(entities, events, dt) {
|
|
36
35
|
if (!this.enabled) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Collider } from '../CollideComponent';
|
|
2
2
|
export declare function shouldCollider(colA: Collider, colB: Collider): boolean;
|
|
3
|
+
export declare function getMin(arr: number[]): number | null;
|
|
4
|
+
export declare function getMax(arr: number[]): number | null;
|
|
3
5
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/collider/helper/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAG9C,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,WAQ5D"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/collider/helper/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAG9C,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,WAQ5D;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAUnD;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAUnD"}
|
|
@@ -9,3 +9,25 @@ export function shouldCollider(colA, colB) {
|
|
|
9
9
|
const { colliderMatrix } = GameWorld.Instance.systems.get(CollideSystem);
|
|
10
10
|
return colliderMatrix[groupA][groupB];
|
|
11
11
|
}
|
|
12
|
+
export function getMin(arr) {
|
|
13
|
+
if (arr.length === 0)
|
|
14
|
+
return null;
|
|
15
|
+
let min = arr[0];
|
|
16
|
+
for (let i = 1; i < arr.length; i++) {
|
|
17
|
+
if (arr[i] < min) {
|
|
18
|
+
min = arr[i];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return min;
|
|
22
|
+
}
|
|
23
|
+
export function getMax(arr) {
|
|
24
|
+
if (arr.length === 0)
|
|
25
|
+
return null;
|
|
26
|
+
let max = arr[0];
|
|
27
|
+
for (let i = 1; i < arr.length; i++) {
|
|
28
|
+
if (arr[i] > max) {
|
|
29
|
+
max = arr[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return max;
|
|
33
|
+
}
|
package/dist/collider/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collider/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collider/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAE/B,wBAAgB,aAAa,CAAC,cAAc,CAAC,KAAA,EAAE,KAAK,UAAQ,QAS3D"}
|
package/dist/collider/index.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
import { GameWorld } from '..';
|
|
2
|
+
import { CollideSystem, enabledDebugDraw } from './CollideSystem';
|
|
1
3
|
export * from './CollideComponent';
|
|
2
4
|
export * from './CollideSystem';
|
|
5
|
+
export function setupCollider(colliderMatrix, debug = false) {
|
|
6
|
+
GameWorld.Instance.systems.add(CollideSystem);
|
|
7
|
+
GameWorld.Instance.listUpdate.push(CollideSystem);
|
|
8
|
+
GameWorld.Instance.systems.configureOnce(CollideSystem);
|
|
9
|
+
const collideSystem = GameWorld.Instance.systems.get(CollideSystem);
|
|
10
|
+
if (colliderMatrix) {
|
|
11
|
+
collideSystem.colliderMatrix = colliderMatrix;
|
|
12
|
+
}
|
|
13
|
+
enabledDebugDraw(debug);
|
|
14
|
+
}
|
|
@@ -34,10 +34,12 @@ export declare class NodeComp<C extends Container = Container> {
|
|
|
34
34
|
get uuid(): number;
|
|
35
35
|
get position(): Point;
|
|
36
36
|
set position(val: Point);
|
|
37
|
-
get
|
|
38
|
-
set
|
|
39
|
-
get
|
|
40
|
-
set
|
|
37
|
+
get posX(): number;
|
|
38
|
+
set posX(val: number);
|
|
39
|
+
get posY(): number;
|
|
40
|
+
set posY(val: number);
|
|
41
|
+
set xy(val: [number, number]);
|
|
42
|
+
get scale(): number;
|
|
41
43
|
set scale(val: number);
|
|
42
44
|
get scaleX(): number;
|
|
43
45
|
set scaleX(val: number);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/components/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/components/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,MAAM,EAAiB,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAgB,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAe,MAAM,SAAS,CAAA;AAEvE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,OAAA,KAAK,IAAI,CAAA;AACjD,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAA;CACnC;AAED,KAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,KAAK,IAAI,CAAA;AAE/D,qBAAa,QAAQ,CAAC,CAAC,SAAS,SA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
import remove from 'lodash/remove';
|
|
2
1
|
import { actionManager } from 'pixi-action-ease';
|
|
3
2
|
import { Point, Sprite, Text } from 'pixi.js';
|
|
4
3
|
import { instantiate } from '../base';
|
|
@@ -53,21 +52,24 @@ export class NodeComp {
|
|
|
53
52
|
set position(val) {
|
|
54
53
|
this.setPosition(val.x, val.y);
|
|
55
54
|
}
|
|
56
|
-
get
|
|
55
|
+
get posX() {
|
|
57
56
|
return this.instance.x;
|
|
58
57
|
}
|
|
59
|
-
set
|
|
58
|
+
set posX(val) {
|
|
60
59
|
this.instance.x = val;
|
|
61
60
|
}
|
|
62
|
-
get
|
|
61
|
+
get posY() {
|
|
63
62
|
return this.instance.y;
|
|
64
63
|
}
|
|
65
|
-
set
|
|
64
|
+
set posY(val) {
|
|
66
65
|
this.instance.y = val;
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
set xy(val) {
|
|
68
|
+
this.setPosition(val[0], val[1]);
|
|
69
|
+
}
|
|
70
|
+
get scale() {
|
|
71
|
+
return this.instance.scale.x;
|
|
72
|
+
}
|
|
71
73
|
set scale(val) {
|
|
72
74
|
this.instance.scale = new Point(val, val);
|
|
73
75
|
}
|
|
@@ -201,12 +203,10 @@ export class NodeComp {
|
|
|
201
203
|
}
|
|
202
204
|
setPosition(x, y) {
|
|
203
205
|
if (typeof x !== 'number') {
|
|
204
|
-
this.
|
|
205
|
-
this.y = x.y;
|
|
206
|
+
this.instance.position = new Point(x.x, x.y);
|
|
206
207
|
}
|
|
207
208
|
else {
|
|
208
|
-
this.
|
|
209
|
-
this.y = y;
|
|
209
|
+
this.instance.position = new Point(x, y);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
setRotation(deg) {
|
|
@@ -273,7 +273,7 @@ export class NodeComp {
|
|
|
273
273
|
}
|
|
274
274
|
destroy() {
|
|
275
275
|
if (this.parent) {
|
|
276
|
-
|
|
276
|
+
this.parent.children = this.parent.children.filter(({ entity }) => entity.id !== this.entity.id);
|
|
277
277
|
}
|
|
278
278
|
this.children.forEach((child) => {
|
|
279
279
|
child.destroy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scene.d.ts","sourceRoot":"","sources":["../../src/components/Scene.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Scene.d.ts","sourceRoot":"","sources":["../../src/components/Scene.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAa,MAAM,SAAS,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,qBAAa,cAAe,SAAQ,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC;IACjE,MAAM;CAWP"}
|
package/dist/components/Scene.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { app } from '../app';
|
|
2
1
|
import { EnhancedComponent, GameWorld } from '../base';
|
|
3
2
|
import { NodeComp } from './NodeComp';
|
|
4
3
|
export class SceneComponent extends EnhancedComponent {
|
|
@@ -6,9 +5,9 @@ export class SceneComponent extends EnhancedComponent {
|
|
|
6
5
|
const world = GameWorld.Instance;
|
|
7
6
|
world.entities.reset();
|
|
8
7
|
const root = world.entities.create();
|
|
9
|
-
const node = root.assign(new NodeComp(app.stage, root));
|
|
10
|
-
app.stage.eventMode = 'static';
|
|
11
|
-
app.stage.hitArea = app.screen;
|
|
8
|
+
const node = root.assign(new NodeComp(GameWorld.Instance.app.stage, root));
|
|
9
|
+
GameWorld.Instance.app.stage.eventMode = 'static';
|
|
10
|
+
GameWorld.Instance.app.stage.hitArea = GameWorld.Instance.app.screen;
|
|
12
11
|
const sceneComponent = root.assign(this);
|
|
13
12
|
sceneComponent.node = node;
|
|
14
13
|
return sceneComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"director.d.ts","sourceRoot":"","sources":["../../src/core/director.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"director.d.ts","sourceRoot":"","sources":["../../src/core/director.ts"],"names":[],"mappings":"AAIA,wBAAgB,QAAQ,SAEvB;AAED,wBAAgB,SAAS,SAExB"}
|
package/dist/core/director.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { app } from "../app"
|
|
1
|
+
// import { app } from "../app"
|
|
2
|
+
import { GameWorld } from "..";
|
|
2
3
|
export function pauseAll() {
|
|
3
|
-
app.ticker.stop();
|
|
4
|
+
GameWorld.Instance.app.ticker.stop();
|
|
4
5
|
}
|
|
5
6
|
export function resumeAll() {
|
|
6
|
-
app.ticker.start();
|
|
7
|
+
GameWorld.Instance.app.ticker.start();
|
|
7
8
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EventManager, System } from 'entityx-ts';
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
2
|
import { GameWorld } from '../base';
|
|
3
3
|
export declare class DragonBonesSystem implements System {
|
|
4
4
|
configure(event_manager: EventManager<GameWorld>): void;
|
|
5
|
+
update(entities: EntityManager, events: EventManager<GameWorld>, dt: number): void;
|
|
5
6
|
}
|
|
6
7
|
//# sourceMappingURL=DragonBonesSystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragonBonesSystem.d.ts","sourceRoot":"","sources":["../../src/dragonbones/DragonBonesSystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"DragonBonesSystem.d.ts","sourceRoot":"","sources":["../../src/dragonbones/DragonBonesSystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAC;AAG7E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,qBAAa,iBAAkB,YAAW,MAAM;IAC9C,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,SAAS,CAAC;IAuBhD,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,MAAM;CAE5E"}
|