@safe-engine/cocos 1.6.4 → 1.7.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.
Files changed (31) hide show
  1. package/dist/app.d.ts +2 -2
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/app.js +36 -26
  4. package/dist/box2d-wasm/PhysicsComponent.d.ts +2 -0
  5. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
  6. package/dist/box2d-wasm/PhysicsComponent.js +16 -3
  7. package/dist/box2d-wasm/PhysicsSprite.d.ts +1 -0
  8. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
  9. package/dist/box2d-wasm/PhysicsSprite.js +3 -4
  10. package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -2
  11. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  12. package/dist/box2d-wasm/PhysicsSystem.js +36 -31
  13. package/dist/gworld/components/AnimationComponent.d.ts +65 -0
  14. package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
  15. package/dist/gworld/components/AnimationComponent.js +141 -0
  16. package/dist/gworld/components/CollideComponent.d.ts +64 -0
  17. package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
  18. package/dist/gworld/components/CollideComponent.js +265 -0
  19. package/dist/gworld/systems/AnimationSystem.d.ts +6 -0
  20. package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
  21. package/dist/gworld/systems/AnimationSystem.js +30 -0
  22. package/dist/gworld/systems/CollideSystem.d.ts +20 -0
  23. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
  24. package/dist/gworld/systems/CollideSystem.js +171 -0
  25. package/dist/helper/html-text-parser.d.ts +30 -0
  26. package/dist/helper/html-text-parser.d.ts.map +1 -0
  27. package/dist/helper/html-text-parser.js +354 -0
  28. package/dist/index.d.ts +0 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +0 -1
  31. package/package.json +1 -1
package/dist/app.d.ts CHANGED
@@ -6,10 +6,10 @@ interface RunOptions {
6
6
  id: string;
7
7
  renderMode: 0 | 1 | 2;
8
8
  }
9
- export declare function startGame(option: RunOptions, { width, height }: {
9
+ export declare function startGame(defaultFont: string, { width, height }: {
10
10
  width: any;
11
11
  height: any;
12
- }, cb: () => void): void;
12
+ }, option?: Partial<RunOptions>): Promise<void>;
13
13
  export declare function loadAll(assets: string[], cb: (progress: number) => void): void;
14
14
  export declare function loadJsonFromCache<T>(filePath: string): T;
15
15
  export declare const audioEngine: typeof cc.audioEngine;
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,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"}
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,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;;;CAAA,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,iBAwCnG;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
@@ -18,33 +18,43 @@ export function initWorld(defaultFont) {
18
18
  guiSystem.defaultFont = defaultFont;
19
19
  }
20
20
  }
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();
21
+ export async function startGame(defaultFont, { width, height }, option) {
22
+ return new Promise((resolve) => {
23
+ class BootScene extends cc.Scene {
24
+ constructor() {
25
+ super();
26
+ super.ctor(); // always call this for compatibility with cocos2dx JS Javascript class system
27
+ this.scheduleUpdate();
28
+ }
29
+ onEnter() {
30
+ super.onEnter();
31
+ initWorld(defaultFont);
32
+ resolve();
33
+ }
34
+ update(dt) {
35
+ GameWorld.Instance.update(dt);
36
+ }
27
37
  }
28
- onEnter() {
29
- super.onEnter();
30
- cb();
31
- }
32
- update(dt) {
33
- GameWorld.Instance.update(dt);
34
- }
35
- }
36
- cc._isContextMenuEnable = true;
37
- cc.game.run(option, function onStart() {
38
- // Pass true to enable retina display, disabled by default to improve performance
39
- cc.view.enableRetina(cc.sys.os === cc.sys.OS_IOS);
40
- // Adjust viewport meta
41
- cc.view.adjustViewPort(true);
42
- // Setup the resolution policy and design resolution size
43
- const policy = width > height ? cc.ResolutionPolicy.FIXED_HEIGHT : cc.ResolutionPolicy.FIXED_WIDTH;
44
- cc.view.setDesignResolutionSize(width, height, policy);
45
- // The game will be resized when browser size change
46
- cc.view.resizeWithBrowserSize(true);
47
- cc.director.runScene(new BootScene());
38
+ cc._isContextMenuEnable = true;
39
+ cc.game.run({
40
+ debugMode: 1,
41
+ showFPS: false,
42
+ frameRate: 60,
43
+ id: 'gameCanvas',
44
+ renderMode: 1,
45
+ ...option || {},
46
+ }, function onStart() {
47
+ // Pass true to enable retina display, disabled by default to improve performance
48
+ cc.view.enableRetina(cc.sys.os === cc.sys.OS_IOS);
49
+ // Adjust viewport meta
50
+ cc.view.adjustViewPort(true);
51
+ // Setup the resolution policy and design resolution size
52
+ const policy = width > height ? cc.ResolutionPolicy.FIXED_HEIGHT : cc.ResolutionPolicy.FIXED_WIDTH;
53
+ cc.view.setDesignResolutionSize(width, height, policy);
54
+ // The game will be resized when browser size change
55
+ cc.view.resizeWithBrowserSize(true);
56
+ cc.director.runScene(new BootScene());
57
+ });
48
58
  });
49
59
  }
50
60
  export function loadAll(assets = [], cb) {
@@ -20,6 +20,8 @@ export declare class RigidBody extends NoRenderComponentX<RigidBodyProps> {
20
20
  physicSprite: PhysicsSprite;
21
21
  set linearVelocity(vel: Vec2);
22
22
  get linearVelocity(): Vec2;
23
+ applyForceToCenter(vel: Vec2): void;
24
+ applyLinearImpulseToCenter(vel: Vec2): void;
23
25
  set position(pos: Vec2);
24
26
  get position(): Vec2;
25
27
  }
@@ -1 +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,cA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ACD,qBAAa,sBAAuB,SAAQ,kBAAkB,CAAC,2BAA2B,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;CAAG"}
@@ -8,20 +8,33 @@ export class RigidBody extends NoRenderComponentX {
8
8
  if (!this.node) {
9
9
  return;
10
10
  }
11
- this.physicSprite.getBody().SetLinearVelocity(new box2D.b2Vec2(vel.x, vel.y));
11
+ this.body.SetLinearVelocity(new box2D.b2Vec2(vel.x, vel.y));
12
12
  }
13
13
  get linearVelocity() {
14
14
  if (!this.node) {
15
15
  return Vec2.ZERO;
16
16
  }
17
- const vel = this.physicSprite.getBody().GetLinearVelocity();
17
+ const vel = this.body.GetLinearVelocity();
18
18
  return Vec2(vel);
19
19
  }
20
+ applyForceToCenter(vel) {
21
+ if (!this.node) {
22
+ return;
23
+ }
24
+ this.body.ApplyForceToCenter(new box2D.b2Vec2(vel.x, vel.y), true);
25
+ }
26
+ applyLinearImpulseToCenter(vel) {
27
+ if (!this.node) {
28
+ return;
29
+ }
30
+ // console.log('applyLinearImpulseToCenter', new box2D.b2Vec2(vel.x, vel.y))
31
+ this.body.ApplyLinearImpulseToCenter(new box2D.b2Vec2(vel.x, vel.y), true);
32
+ }
20
33
  set position(pos) {
21
34
  this.physicSprite.node.setPosition(pos.x, pos.y);
22
35
  const physicsPos = new box2D.b2Vec2(pos.x, pos.y);
23
36
  // console.log('SetTransform', pos, physicsPos)
24
- const body = this.physicSprite.getBody();
37
+ const body = this.body;
25
38
  body.SetLinearVelocity(new box2D.b2Vec2(0, 0));
26
39
  body.SetAngularVelocity(0);
27
40
  body.SetAwake(true);
@@ -4,6 +4,7 @@ export declare class PhysicsSprite {
4
4
  constructor(node: cc.Node, body: Box2D.b2Body);
5
5
  update(dt: number): void;
6
6
  getBody(): Box2D.b2Body;
7
+ set position(val: Box2D.b2Vec2);
7
8
  get x(): number;
8
9
  get y(): number;
9
10
  get angle(): number;
@@ -1 +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"}
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;IAK7C,MAAM,CAAC,EAAE,EAAE,MAAM;IAkBjB,OAAO;IAIP,IAAI,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,EAE7B;IASD,IAAI,CAAC,WAEJ;IAED,IAAI,CAAC,WAEJ;IAMD,IAAI,KAAK,WAER;IAED,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI;CAGxB"}
@@ -5,7 +5,6 @@ export class PhysicsSprite {
5
5
  constructor(node, body) {
6
6
  this.node = node;
7
7
  this.physicsBody = body;
8
- this.node.schedule(this.update.bind(this), 0, cc.REPEAT_FOREVER, 0);
9
8
  }
10
9
  update(dt) {
11
10
  if (!this.physicsBody) {
@@ -24,9 +23,9 @@ export class PhysicsSprite {
24
23
  getBody() {
25
24
  return this.physicsBody;
26
25
  }
27
- // set position(val: Box2D.b2Vec2) {
28
- // this.physicsBody.setPosition(val)
29
- // }
26
+ set position(val) {
27
+ this.physicsBody.SetTransform(val, this.node.rotation);
28
+ }
30
29
  // set x(val) {
31
30
  // this.physicsBody.setPosition(Vec2(val, this.y))
32
31
  // }
@@ -4,12 +4,11 @@ export declare const DynamicBody = 2;
4
4
  export declare const KinematicBody = 1;
5
5
  export declare const StaticBody = 0;
6
6
  export declare let box2D: typeof Box2D;
7
- export declare function initBox2d(cb: any): void;
7
+ export declare function initBox2d(): Promise<void>;
8
8
  export declare function setColliderMatrix(colliderMatrix?: boolean[][]): void;
9
9
  export declare class PhysicsSystem implements System {
10
10
  world: Box2D.b2World;
11
11
  listRemoveBody: Box2D.b2Body[];
12
- listRemoveShape: Box2D.b2Shape[];
13
12
  colliderMatrix: boolean[][];
14
13
  graphics: cc.DrawNode;
15
14
  addDebug(): void;
@@ -1 +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,OAAO,EAAoC,IAAI,EAAE,MAAM,IAAI,CAAA;AAM3D,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,eAAO,MAAM,aAAa,IAAI,CAAA;AAC9B,eAAO,MAAM,UAAU,IAAI,CAAA;AAC3B,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,QAAQ;IAKR,SAAS,CAAC,aAAa,EAAE,YAAY;IA4JrC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;IAwBhE,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAIpB;CACF"}
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,OAAO,EAAoC,IAAI,EAAE,MAAM,IAAI,CAAA;AAM3D,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,eAAO,MAAM,aAAa,IAAI,CAAA;AAC9B,eAAO,MAAM,UAAU,IAAI,CAAA;AAC3B,eAAO,IAAI,KAAK,EAAE,OAAO,KAAK,CAAA;AAC9B,wBAAsB,SAAS,kBAE9B;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;IAEnC,cAAc,cAAW;IACzB,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAA;IAErB,QAAQ;IAKR,SAAS,CAAC,aAAa,EAAE,YAAY;IA4JrC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;IA8BhE,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAIpB;CACF"}
@@ -9,11 +9,8 @@ export const DynamicBody = 2;
9
9
  export const KinematicBody = 1;
10
10
  export const StaticBody = 0;
11
11
  export let box2D;
12
- export function initBox2d(cb) {
13
- Box2DFactory().then((b2) => {
14
- box2D = b2;
15
- cb();
16
- });
12
+ export async function initBox2d() {
13
+ box2D = await Box2DFactory();
17
14
  }
18
15
  // Box2D.b2Fixture.prototype.shouldCollide = function (other) {
19
16
  // const nodeThis: NodeComp = this.getBody().getUserData()
@@ -26,14 +23,14 @@ export function setColliderMatrix(colliderMatrix = [[true]]) {
26
23
  physicsSystem.colliderMatrix = colliderMatrix;
27
24
  }
28
25
  const maxTimeStep = 1 / 60;
29
- const velocityIterations = 1;
30
- const positionIterations = 1;
26
+ const velocityIterations = 8;
27
+ const positionIterations = 3;
31
28
  const metadata = {};
32
29
  const pixelsPerMeter = 1;
33
30
  export class PhysicsSystem {
34
31
  world;
35
32
  listRemoveBody = [];
36
- listRemoveShape = [];
33
+ // listRemoveShape: Box2D.b2Shape[] = []
37
34
  colliderMatrix = [[true]];
38
35
  graphics;
39
36
  addDebug() {
@@ -44,60 +41,60 @@ export class PhysicsSystem {
44
41
  const { b2BodyDef, b2FixtureDef, b2PolygonShape, b2CircleShape, b2Vec2, b2World, pointsToVec2Array, getPointer } = box2D;
45
42
  const gravity = new b2Vec2(0, -10);
46
43
  this.world = new b2World(gravity);
47
- console.log('configure PhysicsSystem world', this.world);
44
+ // console.log('configure PhysicsSystem world', this.world)
48
45
  const graphics = new cc.DrawNode();
49
46
  this.graphics = graphics;
50
47
  graphics.zIndex = 1000;
51
48
  const scene = cc.director.getRunningScene();
52
49
  scene.addChild(graphics);
53
- event_manager.subscribe(EventTypes.ComponentAdded, PhysicsBoxCollider, ({ entity, component }) => {
54
- console.log('ComponentAddedEvent PhysicsBoxCollider', component);
50
+ event_manager.subscribe(EventTypes.ComponentAdded, PhysicsBoxCollider, ({ entity, component: box }) => {
51
+ // console.log('ComponentAddedEvent PhysicsBoxCollider', component)
55
52
  let rigidBody = entity.getComponent(RigidBody);
56
53
  if (!rigidBody) {
57
54
  rigidBody = instantiate(RigidBody);
58
55
  entity.assign(rigidBody);
59
56
  }
60
- const { type = StaticBody, gravityScale = 1, density = 1, friction = 0.5, restitution = 0.3 } = rigidBody.props;
61
- const box = component;
62
- const node = entity.getComponent(NodeComp);
57
+ const { type = StaticBody, gravityScale = 1, density = 1, friction = 0.5, restitution = 0.3, isSensor } = rigidBody.props;
63
58
  const { width, height, offset = [] } = box.props;
64
- const [x = 0, y = 0] = offset;
59
+ const node = entity.getComponent(NodeComp);
65
60
  const zero = new b2Vec2(0, 0);
66
- const position = new b2Vec2(node.posX, node.posY);
67
61
  const bd = new b2BodyDef();
68
62
  bd.set_type(type);
69
63
  bd.set_position(zero);
70
64
  bd.set_gravityScale(gravityScale);
71
65
  const body = this.world.CreateBody(bd);
72
66
  rigidBody.body = body;
67
+ const physicsNode = new PhysicsSprite(node.instance, rigidBody.body);
68
+ rigidBody.physicSprite = physicsNode;
69
+ rigidBody.node = node;
73
70
  // console.log('body', type, b2_dynamicBody, b2_staticBody, getPointer(body));
74
71
  // body.setMassData({ mass: 1 } as any)
75
- const physicsNode = new PhysicsSprite(node.instance, body);
72
+ const position = new b2Vec2(node.posX, node.posY);
76
73
  const square = new b2PolygonShape();
74
+ const [x = 0, y = 0] = offset;
77
75
  square.SetAsBox(width / 2, height / 2, new b2Vec2(x, y), 0);
78
76
  const fixtureDef = new b2FixtureDef();
79
77
  fixtureDef.set_shape(square);
80
78
  fixtureDef.set_density(density);
81
79
  fixtureDef.set_friction(friction);
82
80
  fixtureDef.set_restitution(restitution);
83
- body.CreateFixture(fixtureDef);
84
- body.SetTransform(position, 0);
85
- body.SetLinearVelocity(zero);
86
- body.SetAwake(true);
87
- body.SetEnabled(true);
88
- metadata[getPointer(body)] = node;
89
- rigidBody.physicSprite = physicsNode;
90
- rigidBody.node = node;
81
+ fixtureDef.set_isSensor(isSensor);
82
+ rigidBody.body.CreateFixture(fixtureDef);
83
+ rigidBody.body.SetTransform(position, 0);
84
+ rigidBody.body.SetLinearVelocity(zero);
85
+ rigidBody.body.SetAwake(true);
86
+ rigidBody.body.SetEnabled(true);
87
+ metadata[getPointer(rigidBody.body)] = node;
91
88
  box.node = node;
92
89
  });
93
90
  event_manager.subscribe(EventTypes.ComponentAdded, PhysicsCircleCollider, ({ entity, component }) => {
94
- console.log('ComponentAddedEvent PhysicsCircleCollider', component);
91
+ // console.log('ComponentAddedEvent PhysicsCircleCollider', component)
95
92
  let rigidBody = entity.getComponent(RigidBody);
96
93
  if (!rigidBody) {
97
94
  rigidBody = instantiate(RigidBody);
98
95
  entity.assign(rigidBody);
99
96
  }
100
- const { type = StaticBody, gravityScale = 1, density = 1, friction = 0.5, restitution = 0.3 } = rigidBody.props;
97
+ const { type = StaticBody, gravityScale = 1, density = 100, friction = 0.5, restitution = 0.3, isSensor = false } = rigidBody.props;
101
98
  const node = entity.getComponent(NodeComp);
102
99
  const { radius, offset = [] } = component.props;
103
100
  const [x = 0, y = 0] = offset;
@@ -118,6 +115,7 @@ export class PhysicsSystem {
118
115
  const fixtureDef = new b2FixtureDef();
119
116
  fixtureDef.set_shape(circleShape);
120
117
  fixtureDef.set_density(density);
118
+ fixtureDef.set_isSensor(isSensor);
121
119
  fixtureDef.set_friction(friction);
122
120
  fixtureDef.set_restitution(restitution);
123
121
  body.CreateFixture(fixtureDef);
@@ -131,13 +129,13 @@ export class PhysicsSystem {
131
129
  component.node = node;
132
130
  });
133
131
  event_manager.subscribe(EventTypes.ComponentAdded, PhysicsPolygonCollider, ({ entity, component }) => {
134
- console.log('ComponentAddedEvent PhysicsPolygonCollider', component);
132
+ // console.log('ComponentAddedEvent PhysicsPolygonCollider', component)
135
133
  let rigidBody = entity.getComponent(RigidBody);
136
134
  if (!rigidBody) {
137
135
  rigidBody = instantiate(RigidBody);
138
136
  entity.assign(rigidBody);
139
137
  }
140
- const { type = StaticBody, gravityScale = 1, density = 1, friction = 0.5, restitution = 0.3 } = rigidBody.props;
138
+ const { type = StaticBody, gravityScale = 1, density = 1, friction = 0.5, restitution = 0.3, isSensor } = rigidBody.props;
141
139
  const node = entity.getComponent(NodeComp);
142
140
  const { points, offset = [] } = component.props;
143
141
  const [x = 0, y = 0] = offset;
@@ -169,9 +167,10 @@ export class PhysicsSystem {
169
167
  fixtureDef.set_density(density);
170
168
  fixtureDef.set_friction(friction);
171
169
  fixtureDef.set_restitution(restitution);
170
+ fixtureDef.set_isSensor(isSensor);
172
171
  body.CreateFixture(fixtureDef);
173
172
  body.SetTransform(position, 0);
174
- body.SetLinearVelocity(zero);
173
+ // body.SetLinearVelocity(zero)
175
174
  body.SetAwake(true);
176
175
  body.SetEnabled(true);
177
176
  metadata[getPointer(body)] = node;
@@ -193,6 +192,12 @@ export class PhysicsSystem {
193
192
  update(entities, events, dt) {
194
193
  if (this.world) {
195
194
  const { getPointer } = box2D;
195
+ for (const entt of entities.entities_with_components(RigidBody)) {
196
+ const comp = entt.getComponent(RigidBody);
197
+ if (comp.node.active && comp.enabled) {
198
+ comp.physicSprite.update(dt);
199
+ }
200
+ }
196
201
  // remove bodies and shapes
197
202
  this.listRemoveBody.forEach((body) => {
198
203
  if (body) {
@@ -205,7 +210,7 @@ export class PhysicsSystem {
205
210
  // }
206
211
  // })
207
212
  this.listRemoveBody = [];
208
- this.listRemoveShape = [];
213
+ // this.listRemoveShape = []
209
214
  const clampedDelta = Math.min(dt, maxTimeStep);
210
215
  this.world.Step(clampedDelta, velocityIterations, positionIterations);
211
216
  this.graphics.clear();
@@ -0,0 +1,65 @@
1
+ import { EnhancedComponent } from '../gworld/components/EnhancedComponent';
2
+ export declare namespace AnimationClip {
3
+ interface IEvent {
4
+ frame: number;
5
+ func: string;
6
+ params: string[];
7
+ isCalled: boolean;
8
+ }
9
+ }
10
+ export declare enum WrapMode {
11
+ Default = 0,
12
+ Normal = 1,
13
+ Loop = 2,
14
+ PingPong = 22,
15
+ Reverse = 36,
16
+ LoopReverse = 38,
17
+ PingPongReverse = 54
18
+ }
19
+ interface AnimProp {
20
+ frame: number;
21
+ value: number;
22
+ }
23
+ interface SpriteFrameProp {
24
+ frame: number;
25
+ value: string;
26
+ }
27
+ interface CurveData {
28
+ comps: {
29
+ spriteFrame: SpriteFrameProp[];
30
+ nextFrame: number;
31
+ };
32
+ props: {
33
+ [key: string]: AnimProp[];
34
+ };
35
+ }
36
+ export declare class AnimationClip {
37
+ static WrapMode: typeof WrapMode;
38
+ sample: number;
39
+ speed: number;
40
+ wrapMode: WrapMode;
41
+ events: AnimationClip.IEvent[];
42
+ duration: number;
43
+ name: string;
44
+ curveData: CurveData;
45
+ }
46
+ export declare class AnimationComp extends EnhancedComponent {
47
+ defaultClip: AnimationClip;
48
+ clips: AnimationClip[];
49
+ playOnLoad: boolean;
50
+ private isPaused;
51
+ private elapsed;
52
+ private currentClip;
53
+ constructor(defaultClip: AnimationClip, clips: AnimationClip[], playOnLoad: boolean);
54
+ start(): void;
55
+ update(dt: Float): void;
56
+ getAnimationState(name: string): {
57
+ isPlaying: boolean;
58
+ };
59
+ play(name?: string): void;
60
+ pause(): void;
61
+ resume(): void;
62
+ stop(name?: string): void;
63
+ }
64
+ export { };
65
+ //# sourceMappingURL=AnimationComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimationComponent.d.ts","sourceRoot":"","sources":["../../../src/gworld/components/AnimationComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC,UAAiB,MAAM;QACrB,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,QAAQ,EAAE,OAAO,CAAA;KAClB;CACF;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,aAAa,CAAC,MAAM,EAAE,CAAK;IACnC,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,141 @@
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.AnimationComp = exports.AnimationClip = exports.WrapMode = void 0;
19
+ var EnhancedComponent_1 = require("./EnhancedComponent");
20
+ var RenderComponent_1 = require("./RenderComponent");
21
+ var WrapMode;
22
+ (function (WrapMode) {
23
+ WrapMode[WrapMode["Default"] = 0] = "Default";
24
+ WrapMode[WrapMode["Normal"] = 1] = "Normal";
25
+ WrapMode[WrapMode["Loop"] = 2] = "Loop";
26
+ WrapMode[WrapMode["PingPong"] = 22] = "PingPong";
27
+ WrapMode[WrapMode["Reverse"] = 36] = "Reverse";
28
+ WrapMode[WrapMode["LoopReverse"] = 38] = "LoopReverse";
29
+ WrapMode[WrapMode["PingPongReverse"] = 54] = "PingPongReverse";
30
+ })(WrapMode || (exports.WrapMode = WrapMode = {}));
31
+ var AnimationClip = /** @class */ (function () {
32
+ function AnimationClip() {
33
+ this.sample = 60;
34
+ this.speed = 1;
35
+ this.wrapMode = WrapMode.Normal;
36
+ this.events = [];
37
+ this.duration = 0;
38
+ }
39
+ AnimationClip.WrapMode = WrapMode;
40
+ return AnimationClip;
41
+ }());
42
+ exports.AnimationClip = AnimationClip;
43
+ // cc.AnimationClip = AnimationClip;
44
+ var AnimationComp = /** @class */ (function (_super) {
45
+ __extends(AnimationComp, _super);
46
+ function AnimationComp(defaultClip, clips, playOnLoad) {
47
+ var _this = _super.call(this) || this;
48
+ _this.isPaused = true;
49
+ _this.elapsed = 0;
50
+ _this.defaultClip = defaultClip;
51
+ _this.clips = clips;
52
+ _this.playOnLoad = playOnLoad;
53
+ return _this;
54
+ }
55
+ AnimationComp.prototype.start = function () {
56
+ var _this = this;
57
+ if (this.playOnLoad) {
58
+ setTimeout(function () {
59
+ _this.play();
60
+ }, 0);
61
+ }
62
+ // cc.log(this.clips);
63
+ };
64
+ AnimationComp.prototype.update = function (dt) {
65
+ var _this = this;
66
+ if (this.isPaused || !this.node.active) {
67
+ return;
68
+ }
69
+ var _a = this.currentClip, curveData = _a.curveData, wrapMode = _a.wrapMode, events = _a.events, duration = _a.duration, speed = _a.speed;
70
+ this.elapsed += dt * speed;
71
+ var _b = curveData.comps, spriteFrame = _b.spriteFrame, nextFrame = _b.nextFrame;
72
+ var nextFrameTime = spriteFrame[nextFrame].frame;
73
+ events.forEach(function (evt) {
74
+ var func = evt.func, frame = evt.frame, params = evt.params, isCalled = evt.isCalled;
75
+ if (!isCalled && _this.elapsed >= frame) {
76
+ evt.isCalled = true;
77
+ // this.node.emit(func, ...params)
78
+ }
79
+ });
80
+ if (this.elapsed >= nextFrameTime) {
81
+ var imageComp = this.node.getComponent(RenderComponent_1.SpriteRender);
82
+ if (imageComp) {
83
+ imageComp.spriteFrame = spriteFrame[nextFrame].value;
84
+ }
85
+ // cc.log(spriteFrame[nextFrame].value, nextFrameTime);
86
+ curveData.comps.nextFrame += 1;
87
+ curveData.comps.nextFrame = cc.clampf(curveData.comps.nextFrame, 0, spriteFrame.length - 1);
88
+ if (this.elapsed >= duration) {
89
+ if (wrapMode === WrapMode.Loop) {
90
+ curveData.comps.nextFrame = 0;
91
+ this.elapsed = 0;
92
+ events.forEach(function (evt) {
93
+ evt.isCalled = false;
94
+ });
95
+ }
96
+ else {
97
+ this.isPaused = true;
98
+ }
99
+ }
100
+ }
101
+ };
102
+ AnimationComp.prototype.getAnimationState = function (name) {
103
+ return {
104
+ isPlaying: !this.isPaused,
105
+ };
106
+ };
107
+ AnimationComp.prototype.play = function (name) {
108
+ this.elapsed = 0;
109
+ // cc.log('play', name, this.defaultClip.name);
110
+ if (!name) {
111
+ if (!this.defaultClip) {
112
+ return;
113
+ }
114
+ name = this.defaultClip.name;
115
+ }
116
+ else if (this.currentClip && name === this.currentClip.name) {
117
+ return;
118
+ }
119
+ this.currentClip = this.clips.find(function (clip) { return clip.name === name; });
120
+ this.currentClip.curveData.comps.nextFrame = 0;
121
+ // cc.log('name', name, this.currentClip);
122
+ this.currentClip.events.forEach(function (evt) {
123
+ evt.isCalled = false;
124
+ });
125
+ this.isPaused = false;
126
+ };
127
+ AnimationComp.prototype.pause = function () {
128
+ this.node.instance.pause();
129
+ this.isPaused = true;
130
+ };
131
+ AnimationComp.prototype.resume = function () {
132
+ this.node.instance.resume();
133
+ this.isPaused = false;
134
+ };
135
+ AnimationComp.prototype.stop = function (name) {
136
+ this.node.instance.unscheduleAllCallbacks();
137
+ this.isPaused = true;
138
+ };
139
+ return AnimationComp;
140
+ }(EnhancedComponent_1.EnhancedComponent));
141
+ exports.AnimationComp = AnimationComp;
@@ -0,0 +1,64 @@
1
+ import { Vec2 } from '../../polyfills';
2
+ import { NoRenderComponentX } from '../core/decorator';
3
+ interface ColliderProps {
4
+ offset?: Vec2;
5
+ tag?: number;
6
+ enabled?: boolean;
7
+ onCollisionEnter?: (other: Collider) => void;
8
+ onCollisionExit?: (other: Collider) => void;
9
+ onCollisionStay?: (other: Collider) => void;
10
+ }
11
+ export declare class Collider<T = ColliderProps> extends NoRenderComponentX<T> {
12
+ _worldPoints: cc.Vec2[] | cc.Point[];
13
+ _worldPosition: cc.Vec2 | cc.Point;
14
+ _worldRadius: any;
15
+ _AABB: cc.Rect;
16
+ _preAabb: cc.Rect;
17
+ getAABB(): cc.Rect;
18
+ get world(): {
19
+ points: cc.Point[] | cc.Vec2[];
20
+ preAabb: cc.Rect;
21
+ };
22
+ }
23
+ interface BoxColliderProps extends ColliderProps {
24
+ width: number;
25
+ height: number;
26
+ }
27
+ export declare class BoxCollider extends Collider<BoxColliderProps> {
28
+ get size(): cc.Size;
29
+ set size(s: cc.Size);
30
+ update(dt: any, draw: cc.DrawNode): void;
31
+ }
32
+ interface CircleColliderProps extends ColliderProps {
33
+ radius: number;
34
+ }
35
+ export declare class CircleCollider extends Collider<CircleColliderProps> {
36
+ update(dt: any, draw: cc.DrawNode): void;
37
+ }
38
+ interface PolygonColliderProps extends ColliderProps {
39
+ points: Array<Vec2>;
40
+ }
41
+ export declare class PolygonCollider extends Collider<PolygonColliderProps> {
42
+ get points(): Vec2[];
43
+ set points(points: Vec2[]);
44
+ update(dt: any, draw: cc.DrawNode): void;
45
+ }
46
+ export declare enum CollisionType {
47
+ NONE = 0,
48
+ ENTER = 1,
49
+ STAY = 2,
50
+ EXIT = 3
51
+ }
52
+ export declare class Contract {
53
+ _collider1: Collider;
54
+ _collider2: Collider;
55
+ _touching: boolean;
56
+ _isPolygonPolygon: boolean;
57
+ _isCircleCircle: boolean;
58
+ _isPolygonCircle: boolean;
59
+ constructor(collider1: Collider, collider2: Collider);
60
+ updateState(): CollisionType;
61
+ test(): any;
62
+ }
63
+ export {};
64
+ //# sourceMappingURL=CollideComponent.d.ts.map