@safe-engine/cocos 2.2.2 → 2.2.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/app.js CHANGED
@@ -5,10 +5,10 @@ import { RenderSystem } from './render';
5
5
  export function initWorld(defaultFont) {
6
6
  const world = GameWorld.Instance;
7
7
  world.systems.addThenConfigure(RenderSystem);
8
- const fontSystem = world.systems.addThenConfigure(GUISystem);
8
+ world.systems.addThenConfigure(GUISystem);
9
9
  world.systems.addThenConfigure(NoRenderSystem);
10
10
  if (defaultFont) {
11
- fontSystem.defaultFont = defaultFont;
11
+ GUISystem.defaultFont = defaultFont;
12
12
  }
13
13
  }
14
14
  export async function startGame(defaultFont, { width, height }, option) {
@@ -1,6 +1,6 @@
1
1
  import { EntityManager, EventManager, System } from 'entityx-ts';
2
2
  export declare class GUISystem implements System {
3
- defaultFont: string;
3
+ static defaultFont: string;
4
4
  configure(event_manager: EventManager): void;
5
5
  private onAddButtonComp;
6
6
  private onAddProgressTimerComp;
@@ -1 +1 @@
1
- {"version":3,"file":"GUISystem.d.ts","sourceRoot":"","sources":["../../src/gui/GUISystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,EAAE,MAAM,YAAY,CAAA;AAMlG,qBAAa,SAAU,YAAW,MAAM;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,aAAa,EAAE,YAAY;IASrC,OAAO,CAAC,eAAe,CAuBtB;IAED,OAAO,CAAC,sBAAsB,CAc7B;IAED,OAAO,CAAC,cAAc,CAcrB;IAED,OAAO,CAAC,mBAAmB,CAU1B;IAED,OAAO,CAAC,yBAAyB,CAOhC;IAED,OAAO,CAAC,cAAc,CAWrB;IAED,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;CAIjE"}
1
+ {"version":3,"file":"GUISystem.d.ts","sourceRoot":"","sources":["../../src/gui/GUISystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,EAAE,MAAM,YAAY,CAAA;AAMlG,qBAAa,SAAU,YAAW,MAAM;IACtC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,aAAa,EAAE,YAAY;IASrC,OAAO,CAAC,eAAe,CAuBtB;IAED,OAAO,CAAC,sBAAsB,CAc7B;IAED,OAAO,CAAC,cAAc,CAerB;IAED,OAAO,CAAC,mBAAmB,CAU1B;IAED,OAAO,CAAC,yBAAyB,CAOhC;IAED,OAAO,CAAC,cAAc,CAWrB;IAED,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;CAIjE"}
@@ -4,7 +4,7 @@ import { TouchEventRegister } from '../norender';
4
4
  import { Vec2 } from '../polyfills';
5
5
  import { BlockInputEventsComp, ButtonComp, FillType, InputComp, LabelComp, ProgressTimerComp, ScrollViewComp } from './GUIComponent';
6
6
  export class GUISystem {
7
- defaultFont;
7
+ static defaultFont;
8
8
  configure(event_manager) {
9
9
  event_manager.subscribe(EventTypes.ComponentAdded, ButtonComp, this.onAddButtonComp);
10
10
  event_manager.subscribe(EventTypes.ComponentAdded, ProgressTimerComp, this.onAddProgressTimerComp);
@@ -53,7 +53,7 @@ export class GUISystem {
53
53
  bar.node = entity.assign(new NodeComp(pTimer, entity));
54
54
  };
55
55
  onAddLabelComp = ({ entity, component: label }) => {
56
- const { string = '', font = this.defaultFont, size = 64, outline, shadow } = label.props;
56
+ const { string = '', font = GUISystem.defaultFont, size = 64, outline, shadow } = label.props;
57
57
  const fontName = cc.path.basename(font, '.ttf');
58
58
  const node = new ccui.Text(string, fontName, size);
59
59
  node.setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM);
@@ -65,6 +65,7 @@ export class GUISystem {
65
65
  const [color, blur, offset] = shadow;
66
66
  node.enableShadow(color, offset, blur);
67
67
  }
68
+ node.ignoreContentAdaptWithSize(false);
68
69
  label.node = entity.assign(new NodeComp(node, entity));
69
70
  };
70
71
  onAddScrollViewComp = ({ entity, component: scrollView }) => {
@@ -87,7 +88,7 @@ export class GUISystem {
87
88
  blockInput.node = node;
88
89
  };
89
90
  onAddInputComp = ({ entity, component: textInput }) => {
90
- const { placeHolder = '', font = this.defaultFont, size = 64, maxLength = 20, isPassword = false } = textInput.props;
91
+ const { placeHolder = '', font = GUISystem.defaultFont, size = 64, maxLength = 20, isPassword = false } = textInput.props;
91
92
  const textField = new ccui.TextField();
92
93
  textField.setPlaceHolder(placeHolder);
93
94
  textField.setFontName(font);
@@ -15,8 +15,9 @@ export declare class SpriteRender extends ComponentX<SpriteRenderProps & BaseCom
15
15
  updateTiled(): void;
16
16
  }
17
17
  interface MaskRenderProps {
18
- type?: number;
19
- segments?: number;
18
+ spriteFrame?: string;
19
+ cropSize?: Size;
20
+ alphaThreshold?: number;
20
21
  inverted?: boolean;
21
22
  }
22
23
  export declare class MaskRender extends ComponentX<MaskRenderProps, cc.ClippingNode> {
@@ -32,10 +33,11 @@ interface GraphicsRenderProps {
32
33
  fillColor?: ColorSource;
33
34
  }
34
35
  export declare class GraphicsRender extends ComponentX<GraphicsRenderProps & BaseComponentProps<GraphicsRender>, cc.DrawNode> {
35
- drawDot(x: any, y: any, r: any): void;
36
+ drawDot(center: Vec2, r: number): void;
36
37
  drawLine(origin: Vec2, destination: Vec2, thickness?: Float, color?: Color4B): void;
37
38
  drawRect(origin: Vec2, destination: Vec2, color?: Color4B): void;
38
39
  drawCircle(center: Vec2, radius: Float, angle?: number, segments?: number, drawLineToCenter?: boolean, lineWidth?: Float, color?: Color4B): void;
40
+ drawSolidCircle(center: Vec2, radius: Float, angle?: number, segments?: number, color?: Color4B): void;
39
41
  drawPoly(points: Vec2[], color?: Color4B, thickness?: Float): void;
40
42
  clear(): void;
41
43
  }
@@ -1 +1 @@
1
- {"version":3,"file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,EAAE,EAAE,CAAC,YAAY,CAAC;IAChH,KAAK;CAGN"}
@@ -21,13 +21,9 @@ export class MaskRender extends ComponentX {
21
21
  export class ParticleComp extends ComponentX {
22
22
  }
23
23
  export class GraphicsRender extends ComponentX {
24
- drawDot(x, y, r) {
25
- this.node.instance.drawDot(cc.p(x, y), r, this.props.fillColor);
24
+ drawDot(center, r) {
25
+ this.node.instance.drawDot(center, r, this.props.fillColor);
26
26
  }
27
- // drawPoint(position: Vec2, pointSize: Float, color: Color4B, pointType = PointType.Rect) {
28
- // }
29
- // // drawPoints(points: Vec2[], color: Color4B) {
30
- // // }
31
27
  drawLine(origin, destination, thickness, color) {
32
28
  this.node.instance.drawSegment(origin, destination, thickness || this.props.lineWidth, color || this.props.strokeColor);
33
29
  }
@@ -39,8 +35,10 @@ export class GraphicsRender extends ComponentX {
39
35
  drawCircle(center, radius, angle = 0, segments = 64, drawLineToCenter = true, lineWidth, color) {
40
36
  this.node.instance.drawCircle(center, radius, angle, segments, drawLineToCenter, lineWidth || this.props.lineWidth, color || this.props.fillColor);
41
37
  }
42
- // drawSolidCircle(origin: Vec2, destination: Vec2, color: Color4B) {
43
- // }
38
+ drawSolidCircle(center, radius, angle = 0, segments = 64, color) {
39
+ this.node.instance.drawCircle(center, radius, angle, segments, true, this.props.lineWidth, color || this.props.fillColor);
40
+ this.node.instance.drawDot(center, radius, this.props.fillColor);
41
+ }
44
42
  // drawQuadBezier(origin: Vec2, destination: Vec2, color: Color4B) {
45
43
  // }
46
44
  // drawCubicBezier(origin: Vec2, destination: Vec2, color: Color4B) {
@@ -50,13 +48,11 @@ export class GraphicsRender extends ComponentX {
50
48
  // drawCatmullRom(points: Vec2[], color: Color4B) {
51
49
  // }
52
50
  drawPoly(points, color, thickness) {
53
- this.node.instance.drawPoly(points, color || this.props.fillColor, thickness || this.props.lineWidth);
51
+ this.node.instance.drawPoly(points, color || this.props.fillColor, thickness || this.props.lineWidth, this.props.strokeColor);
54
52
  }
55
53
  // drawSolidPoly(points: Vec2[], color: Color4B) {
56
54
  // this.node.instance.drawPoly(points, color)
57
55
  // }
58
- // drawDot(points: Vec2[], color: Color4B) {
59
- // }
60
56
  // drawSegment(from: Vec2, to: Vec2, color: Color4B) {
61
57
  // }
62
58
  // drawTriangle(p1: Vec2, p2: Vec2, p3: Vec2, color: Color4B) {
@@ -1 +1 @@
1
- {"version":3,"file":"RenderSystem.d.ts","sourceRoot":"","sources":["../../src/render/RenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,EAAE,MAAM,YAAY,CAAA;AAOlG,oBAAY,WAAW;IACrB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED,qBAAa,YAAa,YAAW,MAAM;IACzC,SAAS,CAAC,aAAa,EAAE,YAAY;IAWrC,OAAO,CAAC,eAAe,CAKtB;IAED,OAAO,CAAC,iBAAiB,CAgBxB;IAED,OAAO,CAAC,eAAe,CAKtB;IAED,OAAO,CAAC,mBAAmB,CAQ1B;IAED,OAAO,CAAC,iBAAiB,CAKxB;IAED,OAAO,CAAC,aAAa,CAKpB;IAED,OAAO,CAAC,iBAAiB,CAUxB;IAED,OAAO,CAAC,iBAAiB,CAKxB;IAED,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;CAIjE"}
1
+ {"version":3,"file":"RenderSystem.d.ts","sourceRoot":"","sources":["../../src/render/RenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,EAAE,MAAM,YAAY,CAAA;AAOlG,oBAAY,WAAW;IACrB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED,qBAAa,YAAa,YAAW,MAAM;IACzC,SAAS,CAAC,aAAa,EAAE,YAAY;IAWrC,OAAO,CAAC,eAAe,CAKtB;IAED,OAAO,CAAC,iBAAiB,CAgBxB;IAED,OAAO,CAAC,eAAe,CAWtB;IAED,OAAO,CAAC,mBAAmB,CAQ1B;IAED,OAAO,CAAC,iBAAiB,CAKxB;IAED,OAAO,CAAC,aAAa,CAKpB;IAED,OAAO,CAAC,iBAAiB,CAUxB;IAED,OAAO,CAAC,iBAAiB,CAKxB;IAED,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;CAIjE"}
@@ -49,10 +49,16 @@ export class RenderSystem {
49
49
  spriteComp.node = ett.assign(new NodeComp(node, ett));
50
50
  };
51
51
  onAddMaskRender = ({ entity, component: maskComp }) => {
52
- const { inverted } = maskComp.props;
53
- const node = new cc.ClippingNode();
54
- node.setInverted(inverted);
55
- maskComp.node = entity.assign(new NodeComp(node, entity));
52
+ const { inverted = false, spriteFrame, cropSize, alphaThreshold = 0.05 } = maskComp.props;
53
+ let stencil = new cc.Sprite(spriteFrame);
54
+ if (cropSize) {
55
+ const { width, height } = cropSize;
56
+ stencil = new cc.LayerColor(cc.Color.WHITE, width, height);
57
+ }
58
+ const clipper = new cc.ClippingNode(stencil);
59
+ clipper.setAlphaThreshold(!spriteFrame ? 1 : alphaThreshold);
60
+ clipper.setInverted(inverted);
61
+ maskComp.node = entity.assign(new NodeComp(clipper, entity));
56
62
  };
57
63
  onAddGraphicsRender = ({ entity }) => {
58
64
  const graphicsComp = entity.getComponent(GraphicsRender);
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextComp.d.ts","sourceRoot":"","sources":["../../src/richtext/RichTextComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAK7C,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAC/G,IAAI,MAAM,IAIM,MAAM,CAFrB;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAoBrB;CACF"}
1
+ {"version":3,"file":"RichTextComp.d.ts","sourceRoot":"","sources":["../../src/richtext/RichTextComp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAK7C,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAC/G,IAAI,MAAM,IAIM,MAAM,CAFrB;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAyBrB;CACF"}
@@ -1,3 +1,4 @@
1
+ import { GUISystem } from '..';
1
2
  import { ComponentX, render } from '../core/decorator';
2
3
  import { HtmlTextParser } from './html-text-parser';
3
4
  const _htmlTextParser = new HtmlTextParser();
@@ -13,16 +14,22 @@ export class RichTextComp extends ComponentX {
13
14
  this.node.instance._richElements = [];
14
15
  this.node.instance._formatTextDirty = true;
15
16
  this.node.instance.formatText();
17
+ const fontSize = this.props.size || 64;
16
18
  for (let index = 0; index < newTextArray.length; index++) {
17
- const { style, text } = newTextArray[index];
18
- const color = style && style.color ? cc.hexToColor(style.color) : cc.Color.WHITE;
19
- const fontName = cc.path.basename(this.props.font, '.ttf');
20
- const richText = ccui.RichElementText.create(index, color, 255, text, fontName, this.props.size || 64);
21
- // if (style && style.newline) {
22
- // console.log('richText', richText)
23
- // this.node.instance._addNewLine()
24
- // }
25
- this.node.instance.pushBackElement(richText);
19
+ const { style = {}, text } = newTextArray[index];
20
+ const fontName = cc.path.basename(this.props.font || GUISystem.defaultFont, '.ttf');
21
+ if (style.outline) {
22
+ // console.log('richText', richText, (ccui as any).RichElementCustomNode)
23
+ const label = new ccui.Text(text, fontName, fontSize);
24
+ label.enableOutline(cc.hexToColor(style.outline.color), style.outline.width || 3);
25
+ const customElem = new ccui.RichElementCustomNode.create(1, cc.color(255, 0, 0), 255, label);
26
+ this.node.instance.pushBackElement(customElem);
27
+ }
28
+ else {
29
+ const color = style.color ? cc.hexToColor(style.color) : cc.Color.WHITE;
30
+ const richText = ccui.RichElementText.create(index, color, 255, text, fontName, fontSize);
31
+ this.node.instance.pushBackElement(richText);
32
+ }
26
33
  }
27
34
  }
28
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@safe-engine/cocos",
3
- "version": "2.2.2",
3
+ "version": "2.2.5",
4
4
  "description": "safe-engine with cocos renderer support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",