@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.
- package/dist/animation/AnimationComponent.d.ts +63 -0
- package/dist/animation/AnimationComponent.d.ts.map +1 -0
- package/dist/animation/AnimationComponent.js +119 -0
- package/dist/animation/AnimationSystem.d.ts +6 -0
- package/dist/animation/AnimationSystem.d.ts.map +1 -0
- package/dist/animation/AnimationSystem.js +22 -0
- package/dist/animation/index.d.ts +2 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/index.js +7 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +40 -65
- 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 +16 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts +12 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSprite.js +51 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts +15 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSystem.js +139 -0
- package/dist/box2d-wasm/debugDraw.d.ts +66 -0
- package/dist/box2d-wasm/debugDraw.d.ts.map +1 -0
- package/dist/box2d-wasm/debugDraw.js +210 -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 +10 -0
- package/dist/collider/CollideComponent.js +98 -159
- package/dist/collider/CollideSystem.js +63 -79
- package/dist/collider/index.d.ts +1 -1
- package/dist/collider/index.d.ts.map +1 -1
- package/dist/collider/index.js +11 -9
- package/dist/dragonbones/PixiDragonBonesSprite.js +15 -19
- package/dist/dragonbones/index.js +38 -68
- package/dist/gworld/components/AnimationComponent.d.ts +2 -2
- package/dist/gworld/components/CollideComponent.d.ts +3 -3
- package/dist/gworld/components/EnhancedComponent.js +29 -36
- package/dist/gworld/components/GUIComponent.js +50 -118
- package/dist/gworld/components/NoRenderComponent.js +25 -65
- package/dist/gworld/components/NodeComp.d.ts.map +1 -1
- package/dist/gworld/components/NodeComp.js +237 -317
- package/dist/gworld/components/RenderComponent.js +46 -104
- package/dist/gworld/core/NodePool.js +13 -20
- package/dist/gworld/core/Scene.js +11 -35
- package/dist/gworld/core/decorator.js +12 -42
- package/dist/gworld/index.js +13 -42
- package/dist/gworld/systems/CollideSystem.d.ts +1 -2
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
- package/dist/gworld/systems/CollideSystem.js +2 -12
- package/dist/gworld/systems/GUISystem.js +105 -120
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -1
- package/dist/gworld/systems/NoRenderSystem.js +70 -80
- package/dist/gworld/systems/RenderSystem.js +64 -78
- package/dist/helper/Intersection.js +33 -40
- package/dist/helper/action.js +8 -21
- package/dist/helper/director.js +2 -6
- package/dist/helper/math.js +9 -15
- package/dist/helper/utils.js +28 -37
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -31
- package/dist/polyfills.js +69 -97
- package/dist/richtext/RichTextComp.js +27 -55
- package/dist/richtext/RichTextSystem.js +17 -25
- package/dist/richtext/html-text-parser.js +36 -40
- package/dist/richtext/index.js +5 -8
- package/dist/safex.js +1 -2
- package/dist/spine/CCSkeleton.d.ts.map +1 -1
- package/dist/spine/CCSkeleton.js +25 -61
- package/dist/spine/CCSkeletonAnimation.js +18 -54
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +1 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +39 -43
- package/dist/spine/CCSkeletonTexture.js +4 -40
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +56 -92
- package/dist/spine/index.js +37 -63
- package/package.json +4 -1
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +0 -77
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosArmatureDisplay.js +0 -227
- package/dist/dragonbones/cocos/CocosFactory.d.ts +0 -128
- package/dist/dragonbones/cocos/CocosFactory.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosFactory.js +0 -231
- package/dist/dragonbones/cocos/CocosSlot.d.ts +0 -49
- package/dist/dragonbones/cocos/CocosSlot.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosSlot.js +0 -385
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +0 -53
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosTextureAtlasData.js +0 -158
- package/dist/dragonbones/dragonBones.d.ts +0 -3
- package/dist/dragonbones/dragonBones.d.ts.map +0 -1
- package/dist/dragonbones/dragonBones.js +0 -4788
- package/dist/helper/NodePool.d.ts +0 -9
- package/dist/helper/NodePool.d.ts.map +0 -1
- package/dist/helper/NodePool.js +0 -29
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { EnhancedComponent } from '../gworld/components/EnhancedComponent';
|
|
2
|
+
export interface IEvent {
|
|
3
|
+
frame: number;
|
|
4
|
+
func: string;
|
|
5
|
+
params: string[];
|
|
6
|
+
isCalled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare enum WrapMode {
|
|
9
|
+
Default = 0,
|
|
10
|
+
Normal = 1,
|
|
11
|
+
Loop = 2,
|
|
12
|
+
PingPong = 22,
|
|
13
|
+
Reverse = 36,
|
|
14
|
+
LoopReverse = 38,
|
|
15
|
+
PingPongReverse = 54
|
|
16
|
+
}
|
|
17
|
+
interface AnimProp {
|
|
18
|
+
frame: number;
|
|
19
|
+
value: number;
|
|
20
|
+
}
|
|
21
|
+
interface SpriteFrameProp {
|
|
22
|
+
frame: number;
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
interface CurveData {
|
|
26
|
+
comps: {
|
|
27
|
+
spriteFrame: SpriteFrameProp[];
|
|
28
|
+
nextFrame: number;
|
|
29
|
+
};
|
|
30
|
+
props: {
|
|
31
|
+
[key: string]: AnimProp[];
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export declare class AnimationClip {
|
|
35
|
+
static WrapMode: typeof WrapMode;
|
|
36
|
+
sample: number;
|
|
37
|
+
speed: number;
|
|
38
|
+
wrapMode: WrapMode;
|
|
39
|
+
events: IEvent[];
|
|
40
|
+
duration: number;
|
|
41
|
+
name: string;
|
|
42
|
+
curveData: CurveData;
|
|
43
|
+
}
|
|
44
|
+
export declare class AnimationComp extends EnhancedComponent {
|
|
45
|
+
defaultClip: AnimationClip;
|
|
46
|
+
clips: AnimationClip[];
|
|
47
|
+
playOnLoad: boolean;
|
|
48
|
+
private isPaused;
|
|
49
|
+
private elapsed;
|
|
50
|
+
private currentClip;
|
|
51
|
+
constructor(defaultClip: AnimationClip, clips: AnimationClip[], playOnLoad: boolean);
|
|
52
|
+
start(): void;
|
|
53
|
+
update(dt: Float): void;
|
|
54
|
+
getAnimationState(name: string): {
|
|
55
|
+
isPlaying: boolean;
|
|
56
|
+
};
|
|
57
|
+
play(name?: string): void;
|
|
58
|
+
pause(): void;
|
|
59
|
+
resume(): void;
|
|
60
|
+
stop(name?: string): void;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=AnimationComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationComponent.d.ts","sourceRoot":"","sources":["../../src/animation/AnimationComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAG1E,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,MAAM,IAAI;IACV,IAAI,IAAI;IACR,QAAQ,KAAK;IACb,OAAO,KAAK;IACZ,WAAW,KAAK;IAChB,eAAe,KAAK;CACrB;AAED,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,SAAS;IACjB,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5D,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAA;KAAE,CAAA;CACrC;AAED,qBAAa,aAAa;IACxB,OAAc,QAAQ,kBAAW;IAC1B,MAAM,SAAK;IACX,KAAK,SAAI;IACT,QAAQ,WAAkB;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAK;IACrB,QAAQ,SAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,SAAS,CAAA;CACrB;AAID,qBAAa,aAAc,SAAQ,iBAAiB;IAClD,WAAW,EAAE,aAAa,CAAA;IAC1B,KAAK,EAAE,aAAa,EAAE,CAAA;IACtB,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,QAAQ,CAAO;IACvB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,WAAW,CAAe;gBAEtB,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO;IAOnF,KAAK;IASL,MAAM,CAAC,EAAE,EAAE,KAAK;IAqChB,iBAAiB,CAAC,IAAI,EAAE,MAAM;;;IAMvB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;IAoBlB,KAAK;IAKL,MAAM;IAKN,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;CAI1B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { EnhancedComponent } from '../gworld/components/EnhancedComponent';
|
|
2
|
+
import { SpriteRender } from '../gworld/components/RenderComponent';
|
|
3
|
+
export var WrapMode;
|
|
4
|
+
(function (WrapMode) {
|
|
5
|
+
WrapMode[WrapMode["Default"] = 0] = "Default";
|
|
6
|
+
WrapMode[WrapMode["Normal"] = 1] = "Normal";
|
|
7
|
+
WrapMode[WrapMode["Loop"] = 2] = "Loop";
|
|
8
|
+
WrapMode[WrapMode["PingPong"] = 22] = "PingPong";
|
|
9
|
+
WrapMode[WrapMode["Reverse"] = 36] = "Reverse";
|
|
10
|
+
WrapMode[WrapMode["LoopReverse"] = 38] = "LoopReverse";
|
|
11
|
+
WrapMode[WrapMode["PingPongReverse"] = 54] = "PingPongReverse";
|
|
12
|
+
})(WrapMode || (WrapMode = {}));
|
|
13
|
+
export class AnimationClip {
|
|
14
|
+
static WrapMode = WrapMode;
|
|
15
|
+
sample = 60;
|
|
16
|
+
speed = 1;
|
|
17
|
+
wrapMode = WrapMode.Normal;
|
|
18
|
+
events = [];
|
|
19
|
+
duration = 0;
|
|
20
|
+
name;
|
|
21
|
+
curveData;
|
|
22
|
+
}
|
|
23
|
+
// cc.AnimationClip = AnimationClip;
|
|
24
|
+
export class AnimationComp extends EnhancedComponent {
|
|
25
|
+
defaultClip;
|
|
26
|
+
clips;
|
|
27
|
+
playOnLoad;
|
|
28
|
+
isPaused = true;
|
|
29
|
+
elapsed = 0;
|
|
30
|
+
currentClip;
|
|
31
|
+
constructor(defaultClip, clips, playOnLoad) {
|
|
32
|
+
super();
|
|
33
|
+
this.defaultClip = defaultClip;
|
|
34
|
+
this.clips = clips;
|
|
35
|
+
this.playOnLoad = playOnLoad;
|
|
36
|
+
}
|
|
37
|
+
start() {
|
|
38
|
+
if (this.playOnLoad) {
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
this.play();
|
|
41
|
+
}, 0);
|
|
42
|
+
}
|
|
43
|
+
// cc.log(this.clips);
|
|
44
|
+
}
|
|
45
|
+
update(dt) {
|
|
46
|
+
if (this.isPaused || !this.node.active) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { curveData, wrapMode, events, duration, speed } = this.currentClip;
|
|
50
|
+
this.elapsed += dt * speed;
|
|
51
|
+
const { spriteFrame, nextFrame } = curveData.comps;
|
|
52
|
+
const nextFrameTime = spriteFrame[nextFrame].frame;
|
|
53
|
+
events.forEach((evt) => {
|
|
54
|
+
const { func, frame, params, isCalled } = evt;
|
|
55
|
+
if (!isCalled && this.elapsed >= frame) {
|
|
56
|
+
evt.isCalled = true;
|
|
57
|
+
// this.node.emit(func, ...params)
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (this.elapsed >= nextFrameTime) {
|
|
61
|
+
const imageComp = this.node.getComponent(SpriteRender);
|
|
62
|
+
if (imageComp) {
|
|
63
|
+
imageComp.spriteFrame = spriteFrame[nextFrame].value;
|
|
64
|
+
}
|
|
65
|
+
// cc.log(spriteFrame[nextFrame].value, nextFrameTime);
|
|
66
|
+
curveData.comps.nextFrame += 1;
|
|
67
|
+
curveData.comps.nextFrame = cc.clampf(curveData.comps.nextFrame, 0, spriteFrame.length - 1);
|
|
68
|
+
if (this.elapsed >= duration) {
|
|
69
|
+
if (wrapMode === WrapMode.Loop) {
|
|
70
|
+
curveData.comps.nextFrame = 0;
|
|
71
|
+
this.elapsed = 0;
|
|
72
|
+
events.forEach((evt) => {
|
|
73
|
+
evt.isCalled = false;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.isPaused = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
getAnimationState(name) {
|
|
83
|
+
return {
|
|
84
|
+
isPlaying: !this.isPaused,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
play(name) {
|
|
88
|
+
this.elapsed = 0;
|
|
89
|
+
// cc.log('play', name, this.defaultClip.name);
|
|
90
|
+
if (!name) {
|
|
91
|
+
if (!this.defaultClip) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
name = this.defaultClip.name;
|
|
95
|
+
}
|
|
96
|
+
else if (this.currentClip && name === this.currentClip.name) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.currentClip = this.clips.find((clip) => clip.name === name);
|
|
100
|
+
this.currentClip.curveData.comps.nextFrame = 0;
|
|
101
|
+
// cc.log('name', name, this.currentClip);
|
|
102
|
+
this.currentClip.events.forEach((evt) => {
|
|
103
|
+
evt.isCalled = false;
|
|
104
|
+
});
|
|
105
|
+
this.isPaused = false;
|
|
106
|
+
}
|
|
107
|
+
pause() {
|
|
108
|
+
this.node.instance.pause();
|
|
109
|
+
this.isPaused = true;
|
|
110
|
+
}
|
|
111
|
+
resume() {
|
|
112
|
+
this.node.instance.resume();
|
|
113
|
+
this.isPaused = false;
|
|
114
|
+
}
|
|
115
|
+
stop(name) {
|
|
116
|
+
this.node.instance.unscheduleAllCallbacks();
|
|
117
|
+
this.isPaused = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
|
+
export declare class AnimationSystem implements System {
|
|
3
|
+
configure(event_manager: EventManager): void;
|
|
4
|
+
update(entities: EntityManager, events: EventManager, dt: Float): void;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=AnimationSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationSystem.d.ts","sourceRoot":"","sources":["../../src/animation/AnimationSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAK5E,qBAAa,eAAgB,YAAW,MAAM;IAC5C,SAAS,CAAC,aAAa,EAAE,YAAY;IAQrC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK;CAUhE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventTypes } from 'entityx-ts';
|
|
2
|
+
import { NodeComp } from '../gworld/components/NodeComp';
|
|
3
|
+
import { AnimationComp } from './AnimationComponent';
|
|
4
|
+
export class AnimationSystem {
|
|
5
|
+
configure(event_manager) {
|
|
6
|
+
event_manager.subscribe(EventTypes.ComponentAdded, AnimationComp, ({ entity }) => {
|
|
7
|
+
const animation = entity.getComponent(AnimationComp);
|
|
8
|
+
animation.node = entity.getComponent(NodeComp);
|
|
9
|
+
setTimeout(animation.start.bind(animation), 0);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
update(entities, events, dt) {
|
|
13
|
+
const animations = entities.entities_with_components(AnimationComp);
|
|
14
|
+
// cc.log(animations);
|
|
15
|
+
animations.forEach((ett) => {
|
|
16
|
+
const animation = ett.getComponent(AnimationComp);
|
|
17
|
+
if (animation.node && animation.node.active) {
|
|
18
|
+
animation.update(dt);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/animation/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,SAI7B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GameWorld } from '../gworld';
|
|
2
|
+
import { AnimationSystem } from './AnimationSystem';
|
|
3
|
+
export function setupAnimation() {
|
|
4
|
+
GameWorld.Instance.systems.add(AnimationSystem);
|
|
5
|
+
GameWorld.Instance.listUpdate.push(AnimationSystem);
|
|
6
|
+
GameWorld.Instance.systems.configureOnce(AnimationSystem);
|
|
7
|
+
}
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAMA,wBAAgB,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAMA,wBAAgB,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,QAc7C;AACD,UAAU,UAAU;IAClB,SAAS,EAAE,CAAC,GAAG,CAAC,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;CACtB;AACD,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;;;CAAA,EAAE,EAAE,EAAE,MAAM,IAAI,QA+B9E;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,QA4B5E;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAIxD;AAED,eAAO,MAAM,WAAW,uBAAiB,CAAA"}
|
package/dist/app.js
CHANGED
|
@@ -1,62 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
exports.startGame = startGame;
|
|
21
|
-
exports.loadAll = loadAll;
|
|
22
|
-
exports.loadJsonFromCache = loadJsonFromCache;
|
|
23
|
-
var CollideSystem_1 = require("./collider/CollideSystem");
|
|
24
|
-
var gworld_1 = require("./gworld");
|
|
25
|
-
var GUISystem_1 = require("./gworld/systems/GUISystem");
|
|
26
|
-
var NoRenderSystem_1 = require("./gworld/systems/NoRenderSystem");
|
|
27
|
-
var RenderSystem_1 = require("./gworld/systems/RenderSystem");
|
|
28
|
-
function initWorld(defaultFont) {
|
|
29
|
-
gworld_1.GameWorld.Instance.systems.add(RenderSystem_1.RenderSystem);
|
|
30
|
-
gworld_1.GameWorld.Instance.systems.add(CollideSystem_1.CollideSystem);
|
|
31
|
-
gworld_1.GameWorld.Instance.systems.add(GUISystem_1.GUISystem);
|
|
32
|
-
gworld_1.GameWorld.Instance.systems.add(NoRenderSystem_1.NoRenderSystem);
|
|
33
|
-
gworld_1.GameWorld.Instance.listUpdate.push(CollideSystem_1.CollideSystem);
|
|
34
|
-
gworld_1.GameWorld.Instance.systems.configureOnce(RenderSystem_1.RenderSystem);
|
|
35
|
-
gworld_1.GameWorld.Instance.systems.configureOnce(CollideSystem_1.CollideSystem);
|
|
36
|
-
gworld_1.GameWorld.Instance.systems.configureOnce(GUISystem_1.GUISystem);
|
|
37
|
-
gworld_1.GameWorld.Instance.systems.configureOnce(NoRenderSystem_1.NoRenderSystem);
|
|
38
|
-
var guiSystem = gworld_1.GameWorld.Instance.systems.get(GUISystem_1.GUISystem);
|
|
39
|
-
guiSystem.defaultFont = defaultFont;
|
|
1
|
+
import { CollideSystem } from './collider/CollideSystem';
|
|
2
|
+
import { GameWorld } from './gworld';
|
|
3
|
+
import { GUISystem } from './gworld/systems/GUISystem';
|
|
4
|
+
import { NoRenderSystem } from './gworld/systems/NoRenderSystem';
|
|
5
|
+
import { RenderSystem } from './gworld/systems/RenderSystem';
|
|
6
|
+
export function initWorld(defaultFont) {
|
|
7
|
+
GameWorld.Instance.systems.add(RenderSystem);
|
|
8
|
+
GameWorld.Instance.systems.add(CollideSystem);
|
|
9
|
+
GameWorld.Instance.systems.add(GUISystem);
|
|
10
|
+
GameWorld.Instance.systems.add(NoRenderSystem);
|
|
11
|
+
GameWorld.Instance.listUpdate.push(CollideSystem);
|
|
12
|
+
GameWorld.Instance.systems.configureOnce(RenderSystem);
|
|
13
|
+
GameWorld.Instance.systems.configureOnce(CollideSystem);
|
|
14
|
+
GameWorld.Instance.systems.configureOnce(GUISystem);
|
|
15
|
+
GameWorld.Instance.systems.configureOnce(NoRenderSystem);
|
|
16
|
+
if (defaultFont) {
|
|
17
|
+
const guiSystem = GameWorld.Instance.systems.get(GUISystem);
|
|
18
|
+
guiSystem.defaultFont = defaultFont;
|
|
19
|
+
}
|
|
40
20
|
}
|
|
41
|
-
function startGame(option,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_super.prototype.ctor.call(_this); // always call this for compatibility with cocos2dx JS Javascript class system
|
|
48
|
-
_this.scheduleUpdate();
|
|
49
|
-
return _this;
|
|
21
|
+
export function startGame(option, { width, height }, cb) {
|
|
22
|
+
class BootScene extends cc.Scene {
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
super.ctor(); // always call this for compatibility with cocos2dx JS Javascript class system
|
|
26
|
+
this.scheduleUpdate();
|
|
50
27
|
}
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
onEnter() {
|
|
29
|
+
super.onEnter();
|
|
53
30
|
cb();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}(cc.Scene));
|
|
31
|
+
}
|
|
32
|
+
update(dt) {
|
|
33
|
+
GameWorld.Instance.update(dt);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
60
36
|
cc._isContextMenuEnable = true;
|
|
61
37
|
cc.game.run(option, function onStart() {
|
|
62
38
|
// Pass true to enable retina display, disabled by default to improve performance
|
|
@@ -64,16 +40,15 @@ function startGame(option, _a, cb) {
|
|
|
64
40
|
// Adjust viewport meta
|
|
65
41
|
cc.view.adjustViewPort(true);
|
|
66
42
|
// Setup the resolution policy and design resolution size
|
|
67
|
-
|
|
43
|
+
const policy = width > height ? cc.ResolutionPolicy.FIXED_HEIGHT : cc.ResolutionPolicy.FIXED_WIDTH;
|
|
68
44
|
cc.view.setDesignResolutionSize(width, height, policy);
|
|
69
45
|
// The game will be resized when browser size change
|
|
70
46
|
cc.view.resizeWithBrowserSize(true);
|
|
71
47
|
cc.director.runScene(new BootScene());
|
|
72
48
|
});
|
|
73
49
|
}
|
|
74
|
-
function loadAll(assets, cb) {
|
|
75
|
-
|
|
76
|
-
cc.loader.load(assets.map(function (value) {
|
|
50
|
+
export function loadAll(assets = [], cb) {
|
|
51
|
+
cc.loader.load(assets.map((value) => {
|
|
77
52
|
if (value.endsWith('.ttf')) {
|
|
78
53
|
return {
|
|
79
54
|
type: 'font',
|
|
@@ -86,20 +61,20 @@ function loadAll(assets, cb) {
|
|
|
86
61
|
// console.log(result)
|
|
87
62
|
if (result instanceof cc.Texture2D) {
|
|
88
63
|
// cc.textureCache.addImage(result.url)
|
|
89
|
-
|
|
64
|
+
const frame = new cc.SpriteFrame(result.url, cc.rect(0, 0, result.getPixelsWide(), result.getPixelsHigh()));
|
|
90
65
|
// console.log('cc.Texture2D', result, frame)
|
|
91
66
|
cc.spriteFrameCache.addSpriteFrame(frame, result.url);
|
|
92
67
|
}
|
|
93
|
-
|
|
68
|
+
let percent = loadedCount / count;
|
|
94
69
|
percent = Math.min(percent, 1);
|
|
95
70
|
cb(percent);
|
|
96
71
|
}, function () {
|
|
97
72
|
setTimeout(cb, 500, 1);
|
|
98
73
|
});
|
|
99
74
|
}
|
|
100
|
-
function loadJsonFromCache(filePath) {
|
|
101
|
-
|
|
75
|
+
export function loadJsonFromCache(filePath) {
|
|
76
|
+
const res = cc.loader.getRes(filePath);
|
|
102
77
|
// console.log(filePath, res)
|
|
103
78
|
return res;
|
|
104
79
|
}
|
|
105
|
-
|
|
80
|
+
export const audioEngine = cc.audioEngine;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NodeComp } from '..';
|
|
2
|
+
type Meta = {
|
|
3
|
+
[key: number]: NodeComp;
|
|
4
|
+
};
|
|
5
|
+
export declare const makeContactListener: (world: Box2D.b2World, metadata: Meta, box2D: typeof Box2D) => Box2D.JSContactListener & {
|
|
6
|
+
BeginContact(contact: Box2D.b2Contact | number): void;
|
|
7
|
+
EndContact(contact: Box2D.b2Contact | number): void;
|
|
8
|
+
PreSolve(contact: Box2D.b2Contact | number, oldManifold: Box2D.b2Manifold | number): void;
|
|
9
|
+
PostSolve(contact: Box2D.b2Contact | number, impulse: Box2D.b2ContactImpulse | number): void;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=ContactListener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactListener.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/ContactListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AAG7B,KAAK,IAAI,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAA;AACvC,eAAO,MAAM,mBAAmB,GAAI,OAAO,KAAK,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,OAAO,OAAO,KAAK;0BAWnE,KAAK,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI;wBAwBjC,KAAK,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI;sBAmBjC,KAAK,CAAC,SAAS,GAAG,MAAM,eAAe,KAAK,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI;uBAGtE,KAAK,CAAC,SAAS,GAAG,MAAM,WAAW,KAAK,CAAC,gBAAgB,GAAG,MAAM,GAAG,IAAI;CAK/F,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ColliderPhysics } from './PhysicsComponent';
|
|
2
|
+
export const makeContactListener = (world, metadata, box2D) => {
|
|
3
|
+
const { JSContactListener, getPointer, NULL } = box2D;
|
|
4
|
+
function getContactById(contact) {
|
|
5
|
+
for (let contactList = world.GetContactList(); getPointer(contactList) !== getPointer(NULL); contactList = contactList.GetNext()) {
|
|
6
|
+
if (getPointer(contactList) === contact) {
|
|
7
|
+
console.log('contactBegin', contact, getPointer(contactList), getPointer(NULL));
|
|
8
|
+
return contactList;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const listener = Object.assign(new JSContactListener(), {
|
|
13
|
+
BeginContact(contact) {
|
|
14
|
+
if (typeof contact === 'number') {
|
|
15
|
+
contact = getContactById(contact);
|
|
16
|
+
}
|
|
17
|
+
const ett1 = metadata[getPointer(contact.GetFixtureA().GetBody())];
|
|
18
|
+
const ett2 = metadata[getPointer(contact.GetFixtureB().GetBody())];
|
|
19
|
+
// world.addPostStepCallback(() => {
|
|
20
|
+
// // log('addPostStepCallback');
|
|
21
|
+
// listRemoveShape.forEach((s) => world.removeShape(s))
|
|
22
|
+
// listRemoveBody.forEach((b) => world.removeBody(b))
|
|
23
|
+
// listRemoveBody = []
|
|
24
|
+
// listRemoveShape = []
|
|
25
|
+
// })
|
|
26
|
+
const phys1 = ett1.getComponent(ColliderPhysics);
|
|
27
|
+
const phys2 = ett2.getComponent(ColliderPhysics);
|
|
28
|
+
if (phys1 && phys2) {
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(phys1, 'onCollisionEnter')) {
|
|
30
|
+
phys1.props.onCollisionEnter(phys2);
|
|
31
|
+
}
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(phys2, 'onCollisionEnter')) {
|
|
33
|
+
phys2.props.onCollisionEnter(phys1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
EndContact(contact) {
|
|
38
|
+
if (typeof contact === 'number') {
|
|
39
|
+
contact = getContactById(contact);
|
|
40
|
+
}
|
|
41
|
+
const ett1 = metadata[getPointer(contact.GetFixtureA().GetBody())];
|
|
42
|
+
const ett2 = metadata[getPointer(contact.GetFixtureB().GetBody())];
|
|
43
|
+
// const event1 = ett1.getComponent(NodeComp)
|
|
44
|
+
const phys1 = ett1.getComponent(ColliderPhysics);
|
|
45
|
+
const phys2 = ett2.getComponent(ColliderPhysics);
|
|
46
|
+
// const event2 = ett2.getComponent(NodeComp)
|
|
47
|
+
if (phys1 && phys2) {
|
|
48
|
+
if (Object.prototype.hasOwnProperty.call(phys1, 'onCollisionExit')) {
|
|
49
|
+
phys1.props.onCollisionExit(phys2);
|
|
50
|
+
}
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(phys2, 'onCollisionExit')) {
|
|
52
|
+
phys2.props.onCollisionExit(phys1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
PreSolve(contact, oldManifold) {
|
|
57
|
+
console.log('collisionSeparate');
|
|
58
|
+
},
|
|
59
|
+
PostSolve(contact, impulse) {
|
|
60
|
+
console.log('collisionPost');
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return listener;
|
|
64
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NoRenderComponentX } from '../gworld/core/decorator';
|
|
2
|
+
import { Vec2 } from '../polyfills';
|
|
3
|
+
import { PhysicsSprite } from './PhysicsSprite';
|
|
4
|
+
interface RigidBodyProps {
|
|
5
|
+
type?: 'static' | 'dynamic';
|
|
6
|
+
density?: Float;
|
|
7
|
+
restitution?: Float;
|
|
8
|
+
friction?: Float;
|
|
9
|
+
gravityScale?: Float;
|
|
10
|
+
}
|
|
11
|
+
export declare class RigidBody extends NoRenderComponentX<RigidBodyProps> {
|
|
12
|
+
body: Box2D.b2Body;
|
|
13
|
+
}
|
|
14
|
+
interface PhysicsMaterialProps {
|
|
15
|
+
friction?: number;
|
|
16
|
+
restitution?: number;
|
|
17
|
+
density?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class PhysicsMaterial extends NoRenderComponentX<PhysicsMaterialProps> {
|
|
20
|
+
}
|
|
21
|
+
interface ColliderPhysicsProps {
|
|
22
|
+
tag?: number;
|
|
23
|
+
group?: number;
|
|
24
|
+
offset?: Vec2;
|
|
25
|
+
onCollisionEnter?: (other: ColliderPhysics) => void;
|
|
26
|
+
onCollisionExit?: (other: ColliderPhysics) => void;
|
|
27
|
+
onCollisionStay?: (other: ColliderPhysics) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare class ColliderPhysics<T extends ColliderPhysicsProps = ColliderPhysicsProps> extends NoRenderComponentX<T, PhysicsSprite['node']> {
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
instance: PhysicsSprite;
|
|
32
|
+
}
|
|
33
|
+
interface BoxColliderPhysicsProps extends ColliderPhysicsProps {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
}
|
|
37
|
+
export declare class BoxColliderPhysics extends ColliderPhysics<BoxColliderPhysicsProps> {
|
|
38
|
+
}
|
|
39
|
+
interface CircleColliderPhysicsProps extends ColliderPhysicsProps {
|
|
40
|
+
radius: number;
|
|
41
|
+
}
|
|
42
|
+
export declare class CircleColliderPhysics extends ColliderPhysics<CircleColliderPhysicsProps> {
|
|
43
|
+
}
|
|
44
|
+
interface PolygonColliderPhysicsProps extends ColliderPhysicsProps {
|
|
45
|
+
points: Array<Vec2>;
|
|
46
|
+
}
|
|
47
|
+
export declare class PolygonColliderPhysics extends ColliderPhysics<PolygonColliderPhysicsProps> {
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=PhysicsComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhysicsComponent.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/PhysicsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC3B,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,CAAA;CACrB;AAED,qBAAa,SAAU,SAAQ,kBAAkB,CAAC,cAAc,CAAC;IAC/D,IAAI,EAAE,KAAK,CAAC,MAAM,CAAA;CAmBnB;AAED,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AACD,qBAAa,eAAgB,SAAQ,kBAAkB,CAAC,oBAAoB,CAAC;CAAG;AAEhF,UAAU,oBAAoB;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,IAAI,CAAA;IACb,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IACnD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IAClD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;CACnD;AAED,qBAAa,eAAe,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,kBAAkB,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtI,OAAO,UAAO;IACd,QAAQ,EAAE,aAAa,CAAA;CACxB;AAED,UAAU,uBAAwB,SAAQ,oBAAoB;IAC5D,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AACD,qBAAa,kBAAmB,SAAQ,eAAe,CAAC,uBAAuB,CAAC;CAS/E;AACD,UAAU,0BAA2B,SAAQ,oBAAoB;IAC/D,MAAM,EAAE,MAAM,CAAA;CACf;AACD,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,0BAA0B,CAAC;CAAG;AACzF,UAAU,2BAA4B,SAAQ,oBAAoB;IAChE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;CACpB;AACD,qBAAa,sBAAuB,SAAQ,eAAe,CAAC,2BAA2B,CAAC;CAAG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NoRenderComponentX } from '../gworld/core/decorator';
|
|
2
|
+
export class RigidBody extends NoRenderComponentX {
|
|
3
|
+
body;
|
|
4
|
+
}
|
|
5
|
+
export class PhysicsMaterial extends NoRenderComponentX {
|
|
6
|
+
}
|
|
7
|
+
export class ColliderPhysics extends NoRenderComponentX {
|
|
8
|
+
enabled = true;
|
|
9
|
+
instance;
|
|
10
|
+
}
|
|
11
|
+
export class BoxColliderPhysics extends ColliderPhysics {
|
|
12
|
+
}
|
|
13
|
+
export class CircleColliderPhysics extends ColliderPhysics {
|
|
14
|
+
}
|
|
15
|
+
export class PolygonColliderPhysics extends ColliderPhysics {
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class PhysicsSprite {
|
|
2
|
+
node: cc.Node;
|
|
3
|
+
physicsBody: Box2D.b2Body;
|
|
4
|
+
constructor(node: cc.Node, body: Box2D.b2Body);
|
|
5
|
+
update(dt: number): void;
|
|
6
|
+
getBody(): Box2D.b2Body;
|
|
7
|
+
get x(): number;
|
|
8
|
+
get y(): number;
|
|
9
|
+
get angle(): number;
|
|
10
|
+
addChild(child: cc.Node): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=PhysicsSprite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhysicsSprite.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/PhysicsSprite.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IACxB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA;IACb,WAAW,EAAE,KAAK,CAAC,MAAM,CAAA;gBAEb,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM;IAM7C,MAAM,CAAC,EAAE,EAAE,MAAM;IAkBjB,OAAO;IAeP,IAAI,CAAC,WAEJ;IAED,IAAI,CAAC,WAEJ;IAMD,IAAI,KAAK,WAER;IAED,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI;CAGxB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Vec2 } from '../polyfills';
|
|
2
|
+
export class PhysicsSprite {
|
|
3
|
+
node;
|
|
4
|
+
physicsBody;
|
|
5
|
+
constructor(node, body) {
|
|
6
|
+
this.node = node;
|
|
7
|
+
this.physicsBody = body;
|
|
8
|
+
this.node.schedule(this.update.bind(this), 0, cc.REPEAT_FOREVER, 0);
|
|
9
|
+
}
|
|
10
|
+
update(dt) {
|
|
11
|
+
if (!this.physicsBody) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// const pos = this.physicsBody.GetPosition()
|
|
15
|
+
// use cc.lerp to smooth the position update
|
|
16
|
+
const pos = Vec2(cc.lerp(this.node.x, this.physicsBody.GetPosition().x, dt * 10), cc.lerp(this.node.y, this.physicsBody.GetPosition().y, dt * 10));
|
|
17
|
+
this.node.setPosition(pos.x, pos.y);
|
|
18
|
+
// lerp the rotation
|
|
19
|
+
this.node.setRotation(cc.lerp(this.node.rotation, cc.radiansToDegrees(this.physicsBody.GetAngle()), dt * 10));
|
|
20
|
+
// this.node.setRotation(cc.radiansToDegrees(this.physicsBody.GetAngle()))
|
|
21
|
+
// this.node.setScale(1 / pixelsPerMeter)
|
|
22
|
+
// this.node.setScale(1 / this.physicsBody.GetFixtureList().GetShape().GetRadius())
|
|
23
|
+
}
|
|
24
|
+
getBody() {
|
|
25
|
+
return this.physicsBody;
|
|
26
|
+
}
|
|
27
|
+
// set position(val: Box2D.b2Vec2) {
|
|
28
|
+
// this.physicsBody.setPosition(val)
|
|
29
|
+
// }
|
|
30
|
+
// set x(val) {
|
|
31
|
+
// this.physicsBody.setPosition(Vec2(val, this.y))
|
|
32
|
+
// }
|
|
33
|
+
// set y(val) {
|
|
34
|
+
// this.physicsBody.setPosition(Vec2(this.x, val))
|
|
35
|
+
// }
|
|
36
|
+
get x() {
|
|
37
|
+
return this.physicsBody.GetPosition().x;
|
|
38
|
+
}
|
|
39
|
+
get y() {
|
|
40
|
+
return this.physicsBody.GetPosition().x;
|
|
41
|
+
}
|
|
42
|
+
// set angle(val: number) {
|
|
43
|
+
// this.physicsBody.setAngle(val)
|
|
44
|
+
// }
|
|
45
|
+
get angle() {
|
|
46
|
+
return this.physicsBody.GetAngle();
|
|
47
|
+
}
|
|
48
|
+
addChild(child) {
|
|
49
|
+
this.node.addChild(child);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
|
+
export declare let box2D: typeof Box2D;
|
|
3
|
+
export declare function initBox2d(cb: any): void;
|
|
4
|
+
export declare function setColliderMatrix(colliderMatrix?: boolean[][]): void;
|
|
5
|
+
export declare class PhysicsSystem implements System {
|
|
6
|
+
world: Box2D.b2World;
|
|
7
|
+
listRemoveBody: Box2D.b2Body[];
|
|
8
|
+
listRemoveShape: Box2D.b2Shape[];
|
|
9
|
+
colliderMatrix: boolean[][];
|
|
10
|
+
graphics: cc.DrawNode;
|
|
11
|
+
configure(event_manager: EventManager): void;
|
|
12
|
+
update(entities: EntityManager, events: EventManager, dt: number): void;
|
|
13
|
+
set enabled(val: any);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=PhysicsSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhysicsSystem.d.ts","sourceRoot":"","sources":["../../src/box2d-wasm/PhysicsSystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAe5E,eAAO,IAAI,KAAK,EAAE,OAAO,KAAK,CAAA;AAE9B,wBAAgB,SAAS,CAAC,EAAE,KAAA,QAK3B;AASD,wBAAgB,iBAAiB,CAAC,cAAc,cAAW,QAG1D;AAOD,qBAAa,aAAc,YAAW,MAAM;IAC1C,KAAK,EAAE,KAAK,CAAC,OAAO,CAAA;IACpB,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,CAAK;IACnC,eAAe,EAAE,KAAK,CAAC,OAAO,EAAE,CAAK;IACrC,cAAc,cAAW;IACzB,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAA;IAErB,SAAS,CAAC,aAAa,EAAE,YAAY;IA6ErC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;IAwBhE,IAAI,OAAO,CAAC,GAAG,KAAA,EAMd;CACF"}
|