@safe-engine/cocos 1.5.2 → 1.5.5

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.
Files changed (97) hide show
  1. package/dist/animation/AnimationComponent.d.ts +63 -0
  2. package/dist/animation/AnimationComponent.d.ts.map +1 -0
  3. package/dist/animation/AnimationComponent.js +119 -0
  4. package/dist/animation/AnimationSystem.d.ts +6 -0
  5. package/dist/animation/AnimationSystem.d.ts.map +1 -0
  6. package/dist/animation/AnimationSystem.js +22 -0
  7. package/dist/animation/index.d.ts +2 -0
  8. package/dist/animation/index.d.ts.map +1 -0
  9. package/dist/animation/index.js +7 -0
  10. package/dist/app.d.ts.map +1 -1
  11. package/dist/app.js +40 -65
  12. package/dist/box2d-wasm/ContactListener.d.ts +12 -0
  13. package/dist/box2d-wasm/ContactListener.d.ts.map +1 -0
  14. package/dist/box2d-wasm/ContactListener.js +64 -0
  15. package/dist/box2d-wasm/PhysicsComponent.d.ts +50 -0
  16. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -0
  17. package/dist/box2d-wasm/PhysicsComponent.js +16 -0
  18. package/dist/box2d-wasm/PhysicsSprite.d.ts +12 -0
  19. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -0
  20. package/dist/box2d-wasm/PhysicsSprite.js +51 -0
  21. package/dist/box2d-wasm/PhysicsSystem.d.ts +15 -0
  22. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -0
  23. package/dist/box2d-wasm/PhysicsSystem.js +139 -0
  24. package/dist/box2d-wasm/debugDraw.d.ts +66 -0
  25. package/dist/box2d-wasm/debugDraw.d.ts.map +1 -0
  26. package/dist/box2d-wasm/debugDraw.js +210 -0
  27. package/dist/box2d-wasm/index.d.ts +6 -0
  28. package/dist/box2d-wasm/index.d.ts.map +1 -0
  29. package/dist/box2d-wasm/index.js +10 -0
  30. package/dist/collider/CollideComponent.js +98 -159
  31. package/dist/collider/CollideSystem.js +63 -79
  32. package/dist/collider/index.d.ts +1 -1
  33. package/dist/collider/index.d.ts.map +1 -1
  34. package/dist/collider/index.js +11 -9
  35. package/dist/dragonbones/PixiDragonBonesSprite.js +15 -19
  36. package/dist/dragonbones/index.js +38 -68
  37. package/dist/gworld/components/AnimationComponent.d.ts +2 -2
  38. package/dist/gworld/components/CollideComponent.d.ts +3 -3
  39. package/dist/gworld/components/EnhancedComponent.js +29 -36
  40. package/dist/gworld/components/GUIComponent.js +50 -118
  41. package/dist/gworld/components/NoRenderComponent.js +25 -65
  42. package/dist/gworld/components/NodeComp.d.ts.map +1 -1
  43. package/dist/gworld/components/NodeComp.js +237 -317
  44. package/dist/gworld/components/RenderComponent.js +46 -104
  45. package/dist/gworld/core/NodePool.js +13 -20
  46. package/dist/gworld/core/Scene.js +11 -35
  47. package/dist/gworld/core/decorator.js +12 -42
  48. package/dist/gworld/index.js +13 -42
  49. package/dist/gworld/systems/CollideSystem.d.ts +1 -2
  50. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
  51. package/dist/gworld/systems/CollideSystem.js +2 -12
  52. package/dist/gworld/systems/GUISystem.js +105 -120
  53. package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -1
  54. package/dist/gworld/systems/NoRenderSystem.js +70 -80
  55. package/dist/gworld/systems/RenderSystem.js +64 -78
  56. package/dist/helper/Intersection.js +33 -40
  57. package/dist/helper/action.js +8 -21
  58. package/dist/helper/director.js +2 -6
  59. package/dist/helper/math.js +9 -15
  60. package/dist/helper/utils.js +28 -37
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +20 -31
  64. package/dist/polyfills.js +69 -97
  65. package/dist/richtext/RichTextComp.js +27 -55
  66. package/dist/richtext/RichTextSystem.js +17 -25
  67. package/dist/richtext/html-text-parser.js +36 -40
  68. package/dist/richtext/index.js +5 -8
  69. package/dist/safex.js +1 -2
  70. package/dist/spine/CCSkeleton.d.ts.map +1 -1
  71. package/dist/spine/CCSkeleton.js +25 -61
  72. package/dist/spine/CCSkeletonAnimation.js +18 -54
  73. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +1 -1
  74. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -1
  75. package/dist/spine/CCSkeletonCanvasRenderCmd.js +39 -43
  76. package/dist/spine/CCSkeletonTexture.js +4 -40
  77. package/dist/spine/CCSkeletonWebGLRenderCmd.js +56 -92
  78. package/dist/spine/index.js +37 -63
  79. package/package.json +4 -1
  80. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +0 -77
  81. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +0 -1
  82. package/dist/dragonbones/cocos/CocosArmatureDisplay.js +0 -227
  83. package/dist/dragonbones/cocos/CocosFactory.d.ts +0 -128
  84. package/dist/dragonbones/cocos/CocosFactory.d.ts.map +0 -1
  85. package/dist/dragonbones/cocos/CocosFactory.js +0 -231
  86. package/dist/dragonbones/cocos/CocosSlot.d.ts +0 -49
  87. package/dist/dragonbones/cocos/CocosSlot.d.ts.map +0 -1
  88. package/dist/dragonbones/cocos/CocosSlot.js +0 -385
  89. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +0 -53
  90. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +0 -1
  91. package/dist/dragonbones/cocos/CocosTextureAtlasData.js +0 -158
  92. package/dist/dragonbones/dragonBones.d.ts +0 -3
  93. package/dist/dragonbones/dragonBones.d.ts.map +0 -1
  94. package/dist/dragonbones/dragonBones.js +0 -4788
  95. package/dist/helper/NodePool.d.ts +0 -9
  96. package/dist/helper/NodePool.d.ts.map +0 -1
  97. package/dist/helper/NodePool.js +0 -29
@@ -1,20 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pointInPolygon = pointInPolygon;
4
- exports.pointLineDistance = pointLineDistance;
5
- exports.polygonPolygon = polygonPolygon;
6
- exports.circleCircle = circleCircle;
7
- exports.polygonCircle = polygonCircle;
8
- function pointInPolygon(pos, polygon) {
9
- var inside = false;
10
- var x = pos.x;
11
- var y = pos.y;
1
+ export function pointInPolygon(pos, polygon) {
2
+ let inside = false;
3
+ const x = pos.x;
4
+ const y = pos.y;
12
5
  // use some raycasting to test hits
13
6
  // https://github.com/substack/point-in-polygon/blob/master/index.js
14
- var length = polygon.length;
15
- var intersect = false;
16
- for (var i = 0, j = length - 1; i < length; j = i++) {
17
- var xi = polygon[i].x, yi = polygon[i].y, xj = polygon[j].x, yj = polygon[j].y;
7
+ const length = polygon.length;
8
+ let intersect = false;
9
+ for (let i = 0, j = length - 1; i < length; j = i++) {
10
+ const xi = polygon[i].x, yi = polygon[i].y, xj = polygon[j].x, yj = polygon[j].y;
18
11
  intersect = yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
19
12
  if (intersect) {
20
13
  inside = !inside;
@@ -24,12 +17,12 @@ function pointInPolygon(pos, polygon) {
24
17
  }
25
18
  function lineLine(a1, a2, b1, b2) {
26
19
  // jshint camel case:false
27
- var ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);
28
- var ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);
29
- var u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);
20
+ const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);
21
+ const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);
22
+ const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);
30
23
  if (u_b !== 0) {
31
- var ua = ua_t / u_b;
32
- var ub = ub_t / u_b;
24
+ const ua = ua_t / u_b;
25
+ const ub = ub_t / u_b;
33
26
  if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {
34
27
  return true;
35
28
  }
@@ -37,22 +30,22 @@ function lineLine(a1, a2, b1, b2) {
37
30
  return false;
38
31
  }
39
32
  function linePolygon(A, B, polygon) {
40
- var length = polygon.length;
41
- for (var i = 0; i < length; ++i) {
42
- var C = polygon[i];
43
- var D = polygon[(i + 1) % length];
33
+ const length = polygon.length;
34
+ for (let i = 0; i < length; ++i) {
35
+ const C = polygon[i];
36
+ const D = polygon[(i + 1) % length];
44
37
  if (lineLine(A, B, C, D)) {
45
38
  return true;
46
39
  }
47
40
  }
48
41
  return false;
49
42
  }
50
- function pointLineDistance(point, start, end, isSegment) {
51
- var dx = end.x - start.x;
52
- var dy = end.y - start.y;
53
- var d = dx * dx + dy * dy;
54
- var t = ((point.x - start.x) * dx + (point.y - start.y) * dy) / d;
55
- var p;
43
+ export function pointLineDistance(point, start, end, isSegment) {
44
+ let dx = end.x - start.x;
45
+ let dy = end.y - start.y;
46
+ const d = dx * dx + dy * dy;
47
+ const t = ((point.x - start.x) * dx + (point.y - start.y) * dy) / d;
48
+ let p;
56
49
  if (!isSegment) {
57
50
  p = cc.p(start.x + t * dx, start.y + t * dy);
58
51
  }
@@ -74,12 +67,12 @@ function pointLineDistance(point, start, end, isSegment) {
74
67
  dy = point.y - p.y;
75
68
  return Math.sqrt(dx * dx + dy * dy);
76
69
  }
77
- function polygonPolygon(pts1, pts2) {
78
- var i = 0, l = 0;
70
+ export function polygonPolygon(pts1, pts2) {
71
+ let i = 0, l = 0;
79
72
  // check if p1 pts1 intersects pts2
80
73
  for (l = pts1.length; i < l; ++i) {
81
- var a1 = pts1[i];
82
- var a2 = pts1[(i + 1) % l];
74
+ const a1 = pts1[i];
75
+ const a2 = pts1[(i + 1) % l];
83
76
  if (linePolygon(a1, a2, pts2)) {
84
77
  return true;
85
78
  }
@@ -98,17 +91,17 @@ function polygonPolygon(pts1, pts2) {
98
91
  }
99
92
  return false;
100
93
  }
101
- function circleCircle(p1, r1, p2, r2) {
102
- var distance = cc.pDistance(p1, p2);
94
+ export function circleCircle(p1, r1, p2, r2) {
95
+ const distance = cc.pDistance(p1, p2);
103
96
  return distance < r1 + r2;
104
97
  }
105
- function polygonCircle(pts1, p2, r2) {
98
+ export function polygonCircle(pts1, p2, r2) {
106
99
  if (pointInPolygon(p2, pts1)) {
107
100
  return true;
108
101
  }
109
- for (var i = 0, l = pts1.length; i < l; i++) {
110
- var start = i === 0 ? pts1[l - 1] : pts1[i - 1];
111
- var end = pts1[i];
102
+ for (let i = 0, l = pts1.length; i < l; i++) {
103
+ const start = i === 0 ? pts1[l - 1] : pts1[i - 1];
104
+ const end = pts1[i];
112
105
  if (pointLineDistance(p2, start, end, true) < r2) {
113
106
  return true;
114
107
  }
@@ -1,34 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.moveTo = moveTo;
4
- exports.moveBy = moveBy;
5
- exports.scaleTo = scaleTo;
6
- exports.callFunc = callFunc;
7
- exports.sequence = sequence;
8
- exports.repeatForever = repeatForever;
9
- exports.easeBackOut = easeBackOut;
10
- function moveTo(t, to) {
1
+ export function moveTo(t, to) {
11
2
  return cc.moveTo(t, to);
12
3
  }
13
- function moveBy(t, to) {
4
+ export function moveBy(t, to) {
14
5
  return cc.moveBy(t, to);
15
6
  }
16
- function scaleTo(t, x, y) {
7
+ export function scaleTo(t, x, y) {
17
8
  return cc.scaleTo(t, x, y);
18
9
  }
19
- function callFunc(cb, target, data) {
10
+ export function callFunc(cb, target, data) {
20
11
  return cc.callFunc(cb, target, data);
21
12
  }
22
- function sequence() {
23
- var actions = [];
24
- for (var _i = 0; _i < arguments.length; _i++) {
25
- actions[_i] = arguments[_i];
26
- }
27
- return cc.sequence.apply(cc, actions);
13
+ export function sequence(...actions) {
14
+ return cc.sequence(...actions);
28
15
  }
29
- function repeatForever(action) {
16
+ export function repeatForever(action) {
30
17
  return cc.repeatForever(action);
31
18
  }
32
- function easeBackOut(action) {
19
+ export function easeBackOut(action) {
33
20
  return action.easing(cc.easeBackOut());
34
21
  }
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pauseAll = pauseAll;
4
- exports.resumeAll = resumeAll;
5
- function pauseAll() {
1
+ export function pauseAll() {
6
2
  cc.director.pause();
7
3
  }
8
- function resumeAll() {
4
+ export function resumeAll() {
9
5
  cc.director.resume();
10
6
  }
@@ -1,30 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.radiansToDegrees = exports.degreesToRadians = void 0;
4
- exports.randomRangeInt = randomRangeInt;
5
- exports.getMin = getMin;
6
- exports.getMax = getMax;
7
- function randomRangeInt(minInclude, maxExclude) {
1
+ export function randomRangeInt(minInclude, maxExclude) {
8
2
  return Math.round(Math.random() * (maxExclude - minInclude - 1)) + minInclude;
9
3
  }
10
- exports.degreesToRadians = cc.degreesToRadians;
11
- exports.radiansToDegrees = cc.radiansToDegrees;
12
- function getMin(arr) {
4
+ export const degreesToRadians = cc.degreesToRadians;
5
+ export const radiansToDegrees = cc.radiansToDegrees;
6
+ export function getMin(arr) {
13
7
  if (arr.length === 0)
14
8
  return null;
15
- var min = arr[0];
16
- for (var i = 1; i < arr.length; i++) {
9
+ let min = arr[0];
10
+ for (let i = 1; i < arr.length; i++) {
17
11
  if (arr[i] < min) {
18
12
  min = arr[i];
19
13
  }
20
14
  }
21
15
  return min;
22
16
  }
23
- function getMax(arr) {
17
+ export function getMax(arr) {
24
18
  if (arr.length === 0)
25
19
  return null;
26
- var max = arr[0];
27
- for (var i = 1; i < arr.length; i++) {
20
+ let max = arr[0];
21
+ for (let i = 1; i < arr.length; i++) {
28
22
  if (arr[i] > max) {
29
23
  max = arr[i];
30
24
  }
@@ -1,61 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerSystem = registerSystem;
4
- exports.instantiate = instantiate;
5
- exports.loadScene = loadScene;
6
- var entityx_ts_1 = require("entityx-ts");
7
- var __1 = require("..");
8
- var gworld_1 = require("../gworld");
9
- function registerSystem(component) {
10
- if (gworld_1.GameWorld.Instance.systems.isRegistered("".concat(component.name, "System"))) {
1
+ import { EventTypes } from 'entityx-ts';
2
+ import { NodeComp } from '..';
3
+ import { GameWorld } from '../gworld';
4
+ export function registerSystem(component) {
5
+ if (GameWorld.Instance.systems.isRegistered(`${component.name}System`)) {
11
6
  return;
12
7
  }
13
- var NewSystem = /** @class */ (function () {
14
- function NewSystem() {
15
- }
16
- NewSystem.prototype.configure = function (event_manager) {
8
+ class NewSystem {
9
+ configure(event_manager) {
17
10
  console.log('configure registerSystem', component.name);
18
- event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, component, function (event) {
19
- var ett = event.entity;
20
- var newComp = event.component;
21
- newComp.node = ett.getComponent(__1.NodeComp);
11
+ event_manager.subscribe(EventTypes.ComponentAdded, component, (event) => {
12
+ const ett = event.entity;
13
+ const newComp = event.component;
14
+ newComp.node = ett.getComponent(NodeComp);
22
15
  });
23
- event_manager.subscribe(entityx_ts_1.EventTypes.ComponentRemoved, component, function (event) {
24
- var newComp = event.component;
16
+ event_manager.subscribe(EventTypes.ComponentRemoved, component, (event) => {
17
+ const newComp = event.component;
25
18
  if (newComp.destroy) {
26
19
  newComp.destroy();
27
20
  }
28
21
  });
29
- };
30
- NewSystem.prototype.update = function (entities, events, dt) {
31
- for (var _i = 0, _a = entities.entities_with_components(component); _i < _a.length; _i++) {
32
- var entt = _a[_i];
33
- var comp = entt.getComponent(component);
22
+ }
23
+ update(entities, events, dt) {
24
+ for (const entt of entities.entities_with_components(component)) {
25
+ const comp = entt.getComponent(component);
34
26
  // console.log('comp', comp.constructor.name, typeof comp['update'] === 'function')
35
27
  if (comp.node.active && comp.enabled && typeof comp['update'] === 'function') {
36
28
  comp['update'](dt);
37
29
  }
38
30
  }
39
- };
40
- return NewSystem;
41
- }());
42
- Object.defineProperty(NewSystem, 'name', { value: "".concat(component.name, "System") });
43
- gworld_1.GameWorld.Instance.systems.add(NewSystem);
44
- gworld_1.GameWorld.Instance.systems.configureOnce(NewSystem);
45
- gworld_1.GameWorld.Instance.listUpdate.push(NewSystem);
31
+ }
32
+ }
33
+ Object.defineProperty(NewSystem, 'name', { value: `${component.name}System` });
34
+ GameWorld.Instance.systems.add(NewSystem);
35
+ GameWorld.Instance.systems.configureOnce(NewSystem);
36
+ GameWorld.Instance.listUpdate.push(NewSystem);
46
37
  return NewSystem;
47
38
  }
48
- function instantiate(ComponentType, data) {
49
- var instance = new ComponentType(data);
39
+ export function instantiate(ComponentType, data) {
40
+ const instance = new ComponentType(data);
50
41
  instance.init(data);
51
42
  if (!instance.render) {
52
43
  return instance;
53
44
  }
54
45
  return instance.render();
55
46
  }
56
- function loadScene(ComponentType) {
57
- var world = gworld_1.GameWorld.Instance;
47
+ export function loadScene(ComponentType) {
48
+ const world = GameWorld.Instance;
58
49
  world.entities.reset();
59
- var instance = new ComponentType();
50
+ const instance = new ComponentType();
60
51
  instance.render();
61
52
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export * from './app';
2
+ export * from './box2d-wasm';
3
+ export * from './collider';
4
+ export * from './dragonbones';
2
5
  export * from './gworld';
3
6
  export * from './gworld/components/GUIComponent';
4
7
  export * from './gworld/components/NodeComp';
@@ -13,5 +16,7 @@ export * from './helper/math';
13
16
  export * from './helper/utils';
14
17
  export * from './polyfills';
15
18
  export { type Touch } from './polyfills';
19
+ export * from './richtext';
16
20
  export * from './safex';
21
+ export * from './spine';
17
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uCAAuC,CAAA;AACrD,cAAc,qCAAqC,CAAA;AACnD,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uCAAuC,CAAA;AACrD,cAAc,qCAAqC,CAAA;AACnD,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -1,31 +1,20 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./app"), exports);
18
- __exportStar(require("./gworld"), exports);
19
- __exportStar(require("./gworld/components/GUIComponent"), exports);
20
- __exportStar(require("./gworld/components/NodeComp"), exports);
21
- __exportStar(require("./gworld/components/NoRenderComponent"), exports);
22
- __exportStar(require("./gworld/components/RenderComponent"), exports);
23
- __exportStar(require("./gworld/core/decorator"), exports);
24
- __exportStar(require("./gworld/core/Scene"), exports);
25
- __exportStar(require("./gworld/systems/GUISystem"), exports);
26
- __exportStar(require("./helper/action"), exports);
27
- __exportStar(require("./helper/director"), exports);
28
- __exportStar(require("./helper/math"), exports);
29
- __exportStar(require("./helper/utils"), exports);
30
- __exportStar(require("./polyfills"), exports);
31
- __exportStar(require("./safex"), exports);
1
+ export * from './app';
2
+ export * from './box2d-wasm';
3
+ export * from './collider';
4
+ export * from './dragonbones';
5
+ export * from './gworld';
6
+ export * from './gworld/components/GUIComponent';
7
+ export * from './gworld/components/NodeComp';
8
+ export * from './gworld/components/NoRenderComponent';
9
+ export * from './gworld/components/RenderComponent';
10
+ export * from './gworld/core/decorator';
11
+ export * from './gworld/core/Scene';
12
+ export * from './gworld/systems/GUISystem';
13
+ export * from './helper/action';
14
+ export * from './helper/director';
15
+ export * from './helper/math';
16
+ export * from './helper/utils';
17
+ export * from './polyfills';
18
+ export * from './richtext';
19
+ export * from './safex';
20
+ export * from './spine';
package/dist/polyfills.js CHANGED
@@ -1,34 +1,13 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.Touch = exports.BLUE = exports.GREEN = exports.WHITE = exports.BLACK = exports.RED = exports.SpriteType = void 0;
19
- exports.Vec2 = Vec2;
20
- exports.Color4B = Color4B;
21
- exports.Size = Size;
22
- exports.getWinSize = getWinSize;
23
- var Intersection_1 = require("./helper/Intersection");
1
+ import { circleCircle, pointInPolygon, polygonCircle, polygonPolygon } from './helper/Intersection';
24
2
  function updatePoint(p) {
25
- var x = p.x, y = p.y;
3
+ const { x, y } = p;
26
4
  return Vec2(x, y);
27
5
  }
28
- var _Vec2 = /** @class */ (function () {
29
- function _Vec2(x, y) {
30
- if (x === void 0) { x = 0; }
31
- if (y === void 0) { y = 0; }
6
+ class _Vec2 {
7
+ x;
8
+ y;
9
+ static ZERO;
10
+ constructor(x = 0, y = 0) {
32
11
  if (!(this instanceof _Vec2)) {
33
12
  return new _Vec2(x, y);
34
13
  }
@@ -40,106 +19,106 @@ var _Vec2 = /** @class */ (function () {
40
19
  this.x = x;
41
20
  this.y = y;
42
21
  }
43
- _Vec2.prototype.equals = function (other) {
22
+ equals(other) {
44
23
  return this.x === other.x && this.y === other.y;
45
- };
46
- _Vec2.prototype.add = function (value) {
24
+ }
25
+ add(value) {
47
26
  return updatePoint(cc.pAdd(cc.p(this.x, this.y), value));
48
- };
49
- _Vec2.prototype.addSelf = function (value) {
50
- var nor = updatePoint(cc.pAdd(cc.p(this.x, this.y), value));
27
+ }
28
+ addSelf(value) {
29
+ const nor = updatePoint(cc.pAdd(cc.p(this.x, this.y), value));
51
30
  this.x = nor.x;
52
31
  this.y = nor.y;
53
32
  return nor;
54
- };
55
- _Vec2.prototype.sub = function (value) {
33
+ }
34
+ sub(value) {
56
35
  return updatePoint(cc.pSub(cc.p(this.x, this.y), value));
57
- };
58
- _Vec2.prototype.mul = function (multiply) {
36
+ }
37
+ mul(multiply) {
59
38
  return updatePoint(cc.pMult(cc.p(this.x, this.y), multiply));
60
- };
61
- _Vec2.prototype.mulSelf = function (multiply) {
62
- var nor = updatePoint(cc.pMult(cc.p(this.x, this.y), multiply));
39
+ }
40
+ mulSelf(multiply) {
41
+ const nor = updatePoint(cc.pMult(cc.p(this.x, this.y), multiply));
63
42
  this.x = nor.x;
64
43
  this.y = nor.y;
65
44
  return nor;
66
- };
67
- _Vec2.prototype.mag = function () {
45
+ }
46
+ mag() {
68
47
  return cc.pLength(cc.p(this.x, this.y));
69
- };
70
- _Vec2.prototype.normalizeSelf = function () {
71
- var nor = updatePoint(cc.pNormalize(cc.p(this.x, this.y)));
48
+ }
49
+ normalizeSelf() {
50
+ const nor = updatePoint(cc.pNormalize(cc.p(this.x, this.y)));
72
51
  this.x = nor.x;
73
52
  this.y = nor.y;
74
53
  return nor;
75
- };
76
- _Vec2.prototype.normalize = function () {
54
+ }
55
+ normalize() {
77
56
  return updatePoint(cc.pNormalize(cc.p(this.x, this.y)));
78
- };
79
- _Vec2.prototype.cross = function (other) {
57
+ }
58
+ cross(other) {
80
59
  return this.x * other.y - this.y * other.x;
81
- };
82
- _Vec2.prototype.signAngle = function (other) {
83
- var angle = this.angle(other);
60
+ }
61
+ signAngle(other) {
62
+ const angle = this.angle(other);
84
63
  return this.cross(other) < 0 ? -angle : angle;
85
- };
86
- _Vec2.prototype.lengthSqr = function () {
64
+ }
65
+ lengthSqr() {
87
66
  return this.x * this.x + this.y * this.y;
88
- };
89
- _Vec2.prototype.dot = function (other) {
67
+ }
68
+ dot(other) {
90
69
  return this.x * other.x + this.y * other.y;
91
- };
92
- _Vec2.prototype.angle = function (other) {
93
- var magSqr1 = this.lengthSqr();
94
- var magSqr2 = other.lengthSqr();
70
+ }
71
+ angle(other) {
72
+ const magSqr1 = this.lengthSqr();
73
+ const magSqr2 = other.lengthSqr();
95
74
  if (magSqr1 === 0 || magSqr2 === 0) {
96
75
  console.warn('Cant get angle between zero vector');
97
76
  return 0.0;
98
77
  }
99
- var dot = this.dot(other);
100
- var theta = dot / Math.sqrt(magSqr1 * magSqr2);
78
+ const dot = this.dot(other);
79
+ let theta = dot / Math.sqrt(magSqr1 * magSqr2);
101
80
  theta = cc.clampf(theta, -1.0, 1.0);
102
81
  return Math.acos(theta);
103
- };
104
- _Vec2.prototype.distance = function (other) {
82
+ }
83
+ distance(other) {
105
84
  return cc.pDistance(this, other);
106
- };
107
- return _Vec2;
108
- }());
109
- function Vec2(x, y) {
85
+ }
86
+ }
87
+ export function Vec2(x, y) {
110
88
  return new _Vec2(x, y);
111
89
  }
112
90
  cc.Vec2 = _Vec2;
113
91
  Vec2.ZERO = cc.Vec2.ZERO = Object.freeze(Vec2(0, 0));
114
- var SpriteType;
92
+ export var SpriteType;
115
93
  (function (SpriteType) {
116
94
  SpriteType[SpriteType["SIMPLE"] = 0] = "SIMPLE";
117
95
  SpriteType[SpriteType["SLICED"] = 1] = "SLICED";
118
96
  SpriteType[SpriteType["TILED"] = 2] = "TILED";
119
97
  SpriteType[SpriteType["FILLED"] = 3] = "FILLED";
120
98
  SpriteType[SpriteType["MESH"] = 4] = "MESH";
121
- })(SpriteType || (exports.SpriteType = SpriteType = {}));
122
- exports.RED = Color4B(255, 0, 0, 255);
123
- exports.BLACK = Color4B(0, 0, 0, 255);
124
- exports.WHITE = Color4B(255, 255, 255, 255);
125
- exports.GREEN = Color4B(0, 255, 0, 255);
126
- exports.BLUE = Color4B(0, 0, 255, 255);
99
+ })(SpriteType || (SpriteType = {}));
100
+ export const RED = Color4B(255, 0, 0, 255);
101
+ export const BLACK = Color4B(0, 0, 0, 255);
102
+ export const WHITE = Color4B(255, 255, 255, 255);
103
+ export const GREEN = Color4B(0, 255, 0, 255);
104
+ export const BLUE = Color4B(0, 0, 255, 255);
127
105
  cc.Color.DEBUG_FILL_COLOR = cc.color(255, 255, 0, 150);
128
106
  cc.Color.DEBUG_BORDER_COLOR = cc.color(255, 0, 0, 255);
129
107
  cc.Color.prototype.fromHEX = cc.hexToColor;
130
108
  cc.Intersection = {
131
- polygonPolygon: Intersection_1.polygonPolygon,
132
- circleCircle: Intersection_1.circleCircle,
133
- polygonCircle: Intersection_1.polygonCircle,
134
- pointInPolygon: Intersection_1.pointInPolygon,
109
+ polygonPolygon,
110
+ circleCircle,
111
+ polygonCircle,
112
+ pointInPolygon,
135
113
  };
136
- function Color4B(r, g, b, a) {
114
+ export function Color4B(r, g, b, a) {
137
115
  return cc.color(r, g, b, a);
138
116
  }
139
- var _Size = /** @class */ (function () {
140
- function _Size(width, height) {
141
- if (width === void 0) { width = 0; }
142
- if (height === void 0) { height = 0; }
117
+ class _Size {
118
+ width;
119
+ height;
120
+ static ZERO;
121
+ constructor(width = 0, height = 0) {
143
122
  if (!(this instanceof _Size)) {
144
123
  return new _Size(width, height);
145
124
  }
@@ -150,19 +129,12 @@ var _Size = /** @class */ (function () {
150
129
  this.width = width;
151
130
  this.height = height;
152
131
  }
153
- return _Size;
154
- }());
155
- function Size(x, y) {
132
+ }
133
+ export function Size(x, y) {
156
134
  return new _Size(x, y);
157
135
  }
158
- var Touch = /** @class */ (function (_super) {
159
- __extends(Touch, _super);
160
- function Touch() {
161
- return _super !== null && _super.apply(this, arguments) || this;
162
- }
163
- return Touch;
164
- }(cc.Touch));
165
- exports.Touch = Touch;
166
- function getWinSize() {
136
+ export class Touch extends cc.Touch {
137
+ }
138
+ export function getWinSize() {
167
139
  return cc.director.getWinSize();
168
140
  }