@safe-engine/pixi 8.4.3 → 8.4.6

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 (55) hide show
  1. package/dist/app.d.ts +2 -2
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/base/EnhancedComponent.d.ts +3 -2
  4. package/dist/base/EnhancedComponent.d.ts.map +1 -1
  5. package/dist/base/EnhancedComponent.js +1 -1
  6. package/dist/components/NodeComp.d.ts +1 -0
  7. package/dist/components/NodeComp.d.ts.map +1 -1
  8. package/dist/components/NodeComp.js +10 -0
  9. package/dist/core/loader.d.ts +2 -1
  10. package/dist/core/loader.d.ts.map +1 -1
  11. package/dist/core/loader.js +2 -3
  12. package/dist/gui/GUIComponent.d.ts +17 -15
  13. package/dist/gui/GUIComponent.d.ts.map +1 -1
  14. package/dist/gui/GUIComponent.js +2 -9
  15. package/dist/gui/GUISystem.d.ts.map +1 -1
  16. package/dist/gui/GUISystem.js +13 -10
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +0 -1
  20. package/dist/norender/Touch.d.ts +2 -20
  21. package/dist/norender/Touch.d.ts.map +1 -1
  22. package/dist/norender/Touch.js +1 -1
  23. package/dist/render/RenderComponent.d.ts +6 -10
  24. package/dist/render/RenderComponent.d.ts.map +1 -1
  25. package/dist/richtext/RichTextComp.d.ts +2 -1
  26. package/dist/richtext/RichTextComp.d.ts.map +1 -1
  27. package/dist/richtext/RichTextComp.js +1 -1
  28. package/dist/spine/SpineComponent.d.ts +5 -3
  29. package/dist/spine/SpineComponent.d.ts.map +1 -1
  30. package/dist/spine/SpineComponent.js +1 -1
  31. package/dist/spine/lib/Spine.d.ts +2 -2
  32. package/dist/spine/lib/Spine.d.ts.map +1 -1
  33. package/dist/spine/lib/Spine.js +19 -20
  34. package/package.json +5 -5
  35. package/src/app.ts +2 -2
  36. package/src/base/EnhancedComponent.ts +4 -3
  37. package/src/components/NodeComp.ts +8 -0
  38. package/src/core/loader.ts +7 -5
  39. package/src/gui/GUIComponent.ts +31 -35
  40. package/src/gui/GUISystem.ts +12 -9
  41. package/src/index.ts +0 -2
  42. package/src/norender/Touch.ts +3 -3
  43. package/src/render/RenderComponent.ts +17 -17
  44. package/src/richtext/RichTextComp.ts +10 -6
  45. package/src/spine/SpineComponent.ts +5 -5
  46. package/src/spine/lib/Spine.ts +313 -329
  47. package/dist/spine/lib/assets/atlasLoader.d.ts +0 -34
  48. package/dist/spine/lib/assets/atlasLoader.d.ts.map +0 -1
  49. package/dist/spine/lib/assets/atlasLoader.js +0 -122
  50. package/dist/spine/lib/assets/skeletonLoader.d.ts +0 -30
  51. package/dist/spine/lib/assets/skeletonLoader.d.ts.map +0 -1
  52. package/dist/spine/lib/assets/skeletonLoader.js +0 -70
  53. package/src/@types/safex.d.ts +0 -15
  54. package/src/spine/lib/assets/atlasLoader.ts +0 -158
  55. package/src/spine/lib/assets/skeletonLoader.ts +0 -81
@@ -28,12 +28,10 @@
28
28
  *****************************************************************************/
29
29
  import { AnimationState, AnimationStateData, AtlasAttachmentLoader, ClippingAttachment, Color, MeshAttachment, Physics, Pool, RegionAttachment, Skeleton, SkeletonBinary, SkeletonBounds, SkeletonClipping, SkeletonData, SkeletonJson, Vector2, } from '@esotericsoftware/spine-core';
30
30
  import { Assets, Cache, Container, DEG_TO_RAD, fastCopy, Graphics, Texture, Ticker, ViewContainer, } from 'pixi.js';
31
- ;
32
31
  const vectorAux = new Vector2();
33
32
  Skeleton.yDown = true;
34
33
  const clipper = new SkeletonClipping();
35
- ;
36
- const maskPool = new Pool(() => new Graphics);
34
+ const maskPool = new Pool(() => new Graphics());
37
35
  /**
38
36
  * The class to instantiate a {@link Spine} game object in Pixi.
39
37
  * The static method {@link Spine.from} should be used to instantiate a Spine game object.
@@ -92,8 +90,12 @@ export class Spine extends ViewContainer {
92
90
  this.buildId = 0;
93
91
  this.renderPipeId = 'spine';
94
92
  this._didSpineUpdate = false;
95
- this.beforeUpdateWorldTransforms = () => { };
96
- this.afterUpdateWorldTransforms = () => { };
93
+ this.beforeUpdateWorldTransforms = () => {
94
+ /** */
95
+ };
96
+ this.afterUpdateWorldTransforms = () => {
97
+ /** */
98
+ };
97
99
  this.darkTint = false;
98
100
  this._debug = undefined;
99
101
  this._slotsObject = Object.create(null);
@@ -110,9 +112,7 @@ export class Spine extends ViewContainer {
110
112
  this.state = new AnimationState(new AnimationStateData(skeletonData));
111
113
  this.autoUpdate = (_a = options === null || options === void 0 ? void 0 : options.autoUpdate) !== null && _a !== void 0 ? _a : true;
112
114
  // dark tint can be enabled by options, otherwise is enable if at least one slot has tint black
113
- this.darkTint = (options === null || options === void 0 ? void 0 : options.darkTint) === undefined
114
- ? this.skeleton.slots.some(slot => !!slot.data.darkColor)
115
- : options === null || options === void 0 ? void 0 : options.darkTint;
115
+ this.darkTint = (options === null || options === void 0 ? void 0 : options.darkTint) === undefined ? this.skeleton.slots.some((slot) => !!slot.data.darkColor) : options === null || options === void 0 ? void 0 : options.darkTint;
116
116
  const slots = this.skeleton.slots;
117
117
  for (let i = 0; i < slots.length; i++) {
118
118
  this.attachmentCacheData[i] = Object.create(null);
@@ -244,11 +244,11 @@ export class Spine extends ViewContainer {
244
244
  return;
245
245
  }
246
246
  // assign the currentClippingSlot mask to the slot object
247
- let currentClippingSlot = this.currentClippingSlot;
248
- let slotObject = this._slotsObject[slot.data.name];
247
+ const currentClippingSlot = this.currentClippingSlot;
248
+ const slotObject = this._slotsObject[slot.data.name];
249
249
  if (currentClippingSlot && slotObject) {
250
- let slotClipping = currentClippingSlot.slot;
251
- let clippingAttachment = slotClipping.attachment;
250
+ const slotClipping = currentClippingSlot.slot;
251
+ const clippingAttachment = slotClipping.attachment;
252
252
  // create the pixi mask, only the first time and if the clipped slot is the first one clipped by this currentClippingSlot
253
253
  let mask = currentClippingSlot.mask;
254
254
  if (!mask) {
@@ -262,7 +262,7 @@ export class Spine extends ViewContainer {
262
262
  const worldVerticesLength = clippingAttachment.worldVerticesLength;
263
263
  const vertices = currentClippingSlot.vertices;
264
264
  clippingAttachment.computeWorldVertices(slotClipping, 0, worldVerticesLength, vertices, 0, 2);
265
- mask.clear().poly(vertices).stroke({ width: 0 }).fill({ alpha: .25 });
265
+ mask.clear().poly(vertices).stroke({ width: 0 }).fill({ alpha: 0.25 });
266
266
  }
267
267
  slotObject.container.mask = mask;
268
268
  }
@@ -278,7 +278,8 @@ export class Spine extends ViewContainer {
278
278
  if (last) {
279
279
  for (const key in this.clippingSlotToPixiMasks) {
280
280
  const clippingSlotToPixiMask = this.clippingSlotToPixiMasks[key];
281
- if ((!(clippingSlotToPixiMask.slot.attachment instanceof ClippingAttachment) || !clippingSlotToPixiMask.maskComputed) && clippingSlotToPixiMask.mask) {
281
+ if ((!(clippingSlotToPixiMask.slot.attachment instanceof ClippingAttachment) || !clippingSlotToPixiMask.maskComputed) &&
282
+ clippingSlotToPixiMask.mask) {
282
283
  this.removeChild(clippingSlotToPixiMask.mask);
283
284
  maskPool.free(clippingSlotToPixiMask.mask);
284
285
  clippingSlotToPixiMask.mask = undefined;
@@ -368,9 +369,9 @@ export class Spine extends ViewContainer {
368
369
  const { vertices, uvs, indices } = clippedData;
369
370
  for (let i = 0; i < verticesCount; i++) {
370
371
  vertices[i * 2] = clippedVertices[i * 2];
371
- vertices[(i * 2) + 1] = clippedVertices[(i * 2) + 1];
372
- uvs[i * 2] = clippedUVs[(i * 2)];
373
- uvs[(i * 2) + 1] = clippedUVs[(i * 2) + 1];
372
+ vertices[i * 2 + 1] = clippedVertices[i * 2 + 1];
373
+ uvs[i * 2] = clippedUVs[i * 2];
374
+ uvs[i * 2 + 1] = clippedUVs[i * 2 + 1];
374
375
  }
375
376
  clippedData.vertexCount = verticesCount;
376
377
  for (let i = 0; i < indicesCount; i++) {
@@ -613,9 +614,7 @@ export class Spine extends ViewContainer {
613
614
  const skeletonAsset = Assets.get(skeleton);
614
615
  const atlasAsset = Assets.get(atlas);
615
616
  const attachmentLoader = new AtlasAttachmentLoader(atlasAsset);
616
- const parser = skeletonAsset instanceof Uint8Array
617
- ? new SkeletonBinary(attachmentLoader)
618
- : new SkeletonJson(attachmentLoader);
617
+ const parser = skeletonAsset instanceof Uint8Array ? new SkeletonBinary(attachmentLoader) : new SkeletonJson(attachmentLoader);
619
618
  parser.scale = scale;
620
619
  const skeletonData = parser.readSkeletonData(skeletonAsset);
621
620
  Cache.set(cacheKey, skeletonData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@safe-engine/pixi",
3
- "version": "8.4.3",
3
+ "version": "8.4.6",
4
4
  "description": "safex pixi plugin",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,16 +16,16 @@
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
- "@esotericsoftware/spine-core": "^4.2.84",
19
+ "@esotericsoftware/spine-core": "^4.2.87",
20
20
  "@pixi/ui": "^2.2.4",
21
- "@types/node": "^24.0.10",
21
+ "@types/node": "^24.0.15",
22
22
  "box2d-wasm": "^7.0.0",
23
23
  "copyfiles": "^2.4.1",
24
24
  "dragonbones-pixijs": "^1.0.5",
25
25
  "entityx-ts": "^2.2.1",
26
- "pixi-action-ease": "^3.0.6",
26
+ "pixi-action-ease": "^3.2.3",
27
27
  "pixi-tagged-text-plus": "0.0.1-next.2",
28
- "pixi.js": "8.10.2",
28
+ "pixi.js": "8.11.0",
29
29
  "planck": "^1.4.2"
30
30
  },
31
31
  "devDependencies": {
package/src/app.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { actionManager } from 'pixi-action-ease'
2
- import { Application, AssetsClass } from 'pixi.js'
2
+ import { Application, AssetsClass, Renderer } from 'pixi.js'
3
3
 
4
4
  import { GameWorld } from './base'
5
5
  import { CollideSystem } from './collider'
@@ -12,7 +12,7 @@ export async function startGame(
12
12
  designedResolution = { width: 720, height: 1280 },
13
13
  assetManager: AssetsClass,
14
14
  id = 'gameCanvas',
15
- ) {
15
+ ): Promise<Application<Renderer>> {
16
16
  const app = new Application()
17
17
  await app.init({
18
18
  antialias: true,
@@ -1,10 +1,11 @@
1
1
  import { Constructor } from 'entityx-ts'
2
- import { BaseComponentProps } from '../@types/safex'
2
+ import { BaseComponentProps } from '..'
3
3
  import { NodeComp } from '../components/NodeComp'
4
4
 
5
5
  export class EnhancedComponent<Props = {}, N extends NodeComp<any> = NodeComp<any>> {
6
6
  props: Props = {} as any
7
- constructor(data?: BaseComponentProps & Props) {
7
+ enabled = true
8
+ constructor(data?: BaseComponentProps<EnhancedComponent> & Props) {
8
9
  this.init(data)
9
10
  }
10
11
  init(data?: Props) {
@@ -16,7 +17,7 @@ export class EnhancedComponent<Props = {}, N extends NodeComp<any> = NodeComp<an
16
17
  }
17
18
  }
18
19
  node: N
19
- // actionsMap: { [key: string]: Animation } = {}
20
+
20
21
  addComponent<T extends EnhancedComponent>(instance): T {
21
22
  return this.node.addComponent(instance)
22
23
  }
@@ -27,6 +27,7 @@ export class NodeComp<C extends Container = Container> {
27
27
  name: string
28
28
  // private lastMove: { x: number; y: number }
29
29
  private _group = 0
30
+ private _active = true
30
31
 
31
32
  onTouchStart?: TouchEventCallback
32
33
  onTouchMove?: TouchEventCallback
@@ -183,10 +184,17 @@ export class NodeComp<C extends Container = Container> {
183
184
  }
184
185
 
185
186
  get active() {
187
+ if (!this._active) return false
188
+ let p = this.parent
189
+ while (p) {
190
+ if (!p.active) return false
191
+ p = p.parent
192
+ }
186
193
  return this.instance.visible && !this.instance.destroyed
187
194
  }
188
195
 
189
196
  set active(val: boolean) {
197
+ this._active = val
190
198
  this.instance.visible = val
191
199
  }
192
200
 
@@ -1,10 +1,12 @@
1
- import { Assets } from 'pixi.js'
1
+ import { AssetsClass } from 'pixi.js'
2
2
 
3
3
  const jsonCache = {}
4
- export async function loadJsonAsync<T>(filePath: string): Promise<T> {
5
- const json = await Assets.load(filePath)
6
- jsonCache[filePath] = json
7
- return json
4
+ export function loadJsonAsync<T>(Assets: AssetsClass) {
5
+ return async (filePath: string): Promise<T> => {
6
+ const json = await Assets.load(filePath)
7
+ jsonCache[filePath] = json
8
+ return json
9
+ }
8
10
  }
9
11
 
10
12
  export function loadJsonFromCache<T>(filePath: string): T {
@@ -1,6 +1,7 @@
1
1
  import { CheckBox, CheckBoxOptions, Input, List, ProgressBar, RadioGroup, Slider, SliderOptions } from '@pixi/ui'
2
- import { Assets, Container, FillInput, Point, Text } from 'pixi.js'
2
+ import { Assets, Container, Point, Text } from 'pixi.js'
3
3
 
4
+ import { BaseComponentProps } from '..'
4
5
  import { ComponentX, NoRenderComponentX } from '../components/BaseComponent'
5
6
  import { Color4B } from '../core/Color'
6
7
  import { LoadingBarMode, ProgressTimer } from '../core/LoadingBar'
@@ -10,10 +11,10 @@ export const FillType = {
10
11
  VERTICAL: 1,
11
12
  RADIAL: 2,
12
13
  }
13
- type Keys = keyof typeof FillType
14
- type Values = (typeof FillType)[Keys]
14
+ // type Keys = keyof typeof FillType
15
+ // type Values = (typeof FillType)[Keys]
15
16
 
16
- interface ButtonCompProps {
17
+ interface ButtonCompProps extends BaseComponentProps<ButtonComp> {
17
18
  normalImage?: string
18
19
  selectedImage?: string
19
20
  disableImage?: string
@@ -24,10 +25,9 @@ export class ButtonComp extends NoRenderComponentX<ButtonCompProps> {
24
25
  // setOnPress(cb: (target: ButtonComp) => void) {
25
26
  // this.onPress = cb
26
27
  // }
27
-
28
- set enabled(val) {
29
- this.node.instance.interactive = val
30
- }
28
+ // set enabled(val) {
29
+ // this.node.instance.interactive = val
30
+ // }
31
31
  }
32
32
 
33
33
  export class ProgressBarComp extends ComponentX<{}, ProgressBar> {
@@ -44,13 +44,12 @@ export class ProgressBarComp extends ComponentX<{}, ProgressBar> {
44
44
  this.node.instance.progress = val
45
45
  }
46
46
  }
47
- interface LabelCompProps {
47
+ interface LabelCompProps extends BaseComponentProps<LabelComp> {
48
48
  font?: string
49
49
  string?: string
50
50
  size?: number
51
51
  }
52
52
  export class LabelComp extends ComponentX<LabelCompProps, Text> {
53
-
54
53
  get string() {
55
54
  return this.props.string
56
55
  }
@@ -92,21 +91,18 @@ interface ScrollViewProps {
92
91
  width: number
93
92
  height: number
94
93
  }
95
- export class ScrollView extends NoRenderComponentX<ScrollViewProps> {
94
+ export class ScrollView extends NoRenderComponentX<ScrollViewProps> {}
96
95
 
97
- }
96
+ export class BlockInputEventsComp extends NoRenderComponentX {}
98
97
 
99
- export class BlockInputEventsComp extends NoRenderComponentX { }
100
-
101
- interface ProgressTimerProps {
98
+ interface ProgressTimerProps extends BaseComponentProps<ProgressTimerComp> {
102
99
  spriteFrame: string
103
100
  fillType?: number
104
101
  fillRange?: number
105
102
  fillCenter?: Point
106
103
  isReverse?: boolean
107
104
  }
108
- export class ProgressTimerComp extends ComponentX<ProgressTimerProps & { $ref?: ProgressTimerComp }, ProgressTimer> {
109
-
105
+ export class ProgressTimerComp extends ComponentX<ProgressTimerProps, ProgressTimer> {
110
106
  getFillRange() {
111
107
  return this.node.instance.progress
112
108
  }
@@ -125,35 +121,35 @@ interface LabelOutlineCompProps {
125
121
  color: Color4B
126
122
  width: number
127
123
  }
128
- export class LabelOutlineComp extends NoRenderComponentX<LabelOutlineCompProps> {
129
-
130
- }
124
+ export class LabelOutlineComp extends NoRenderComponentX<LabelOutlineCompProps> {}
131
125
 
132
- interface LabelShadowCompProps {
126
+ interface LabelShadowCompProps extends BaseComponentProps<LabelShadowComp> {
133
127
  color: Color4B
134
128
  blur: number
135
129
  offset?: Point
136
130
  }
137
- export class LabelShadowComp extends NoRenderComponentX<LabelShadowCompProps> {
131
+ export class LabelShadowComp extends NoRenderComponentX<LabelShadowCompProps> {}
138
132
 
133
+ interface InputCompProps extends BaseComponentProps<InputComp> {
134
+ placeHolder?: string
135
+ font?: string
136
+ size?: Integer
137
+ maxLength?: Integer
138
+ isPassword?: boolean
139
+ bg?: string
140
+ // fill?: FillInput
139
141
  }
140
-
141
- export class InputComp extends ComponentX<{}, Input> {
142
- bg: string
143
- fill: FillInput
144
- font: string
145
- string: string
146
- size = 64
142
+ export class InputComp extends ComponentX<InputCompProps, Input> {
143
+ get string() {
144
+ return this.node.instance.value
145
+ }
147
146
  }
148
147
 
149
- export class ListComp extends ComponentX<{}, List> {
150
- }
148
+ export class ListComp extends ComponentX<{}, List> {}
151
149
  export class SliderComp extends ComponentX<{}, Slider> {
152
150
  bg: string
153
151
  fill: SliderOptions['fill']
154
152
  slider: Container
155
153
  }
156
- export class RadioGroupComp extends ComponentX<{}, RadioGroup> {
157
- }
158
- export class CheckBoxComp extends ComponentX<{ style: CheckBoxOptions['style'] }, CheckBox> {
159
- }
154
+ export class RadioGroupComp extends ComponentX<{}, RadioGroup> {}
155
+ export class CheckBoxComp extends ComponentX<{ style: CheckBoxOptions['style'] }, CheckBox> {}
@@ -1,14 +1,15 @@
1
- import { Button, CheckBox, List, RadioGroup, ScrollBox } from '@pixi/ui'
1
+ import { Button, CheckBox, Input, List, RadioGroup, ScrollBox } from '@pixi/ui'
2
2
  import { EventManager, EventTypes, System } from 'entityx-ts'
3
3
  import { callFunc, easeBackIn, scaleTo, sequence } from 'pixi-action-ease'
4
4
  import { Text } from 'pixi.js'
5
5
 
6
- import { NodeComp } from '..'
6
+ import { Color4B, NodeComp } from '..'
7
7
  import { GameWorld } from '../base'
8
8
  import { LoadingBarMode, ProgressTimer } from '../core/LoadingBar'
9
9
  import {
10
10
  ButtonComp,
11
11
  CheckBoxComp,
12
+ InputComp,
12
13
  LabelComp,
13
14
  LabelOutlineComp,
14
15
  LabelShadowComp,
@@ -30,6 +31,7 @@ export class GUISystem implements System {
30
31
  component.node = nodeComp
31
32
  // component.node = entity.assign(new NodeComp(node, entity))
32
33
  button.onPress.connect(() => {
34
+ if (!component.enabled) return
33
35
  // console.log('onPress.connect')
34
36
  const scale = scaleTo(0.5, 1.2)
35
37
  const scaleDown = scaleTo(0.5, 1)
@@ -53,11 +55,12 @@ export class GUISystem implements System {
53
55
  // })
54
56
  event_manager.subscribe(EventTypes.ComponentAdded, ProgressTimerComp, ({ entity, component }) => {
55
57
  // console.log(component, '.progress')
56
- const { spriteFrame, fillCenter } = component.props
58
+ const { spriteFrame, fillCenter, fillRange = 0 } = component.props
57
59
  const node = new ProgressTimer(LoadingBarMode.BAR, spriteFrame)
58
60
  if (fillCenter) {
59
61
  node.fillCenter = fillCenter
60
62
  }
63
+ node.progress = fillRange * 100
61
64
  component.node = entity.assign(new NodeComp(node, entity))
62
65
  })
63
66
  event_manager.subscribe(EventTypes.ComponentAdded, ScrollView, ({ entity, component }) => {
@@ -83,11 +86,11 @@ export class GUISystem implements System {
83
86
  const view = new CheckBox({ style })
84
87
  component.node = entity.assign(new NodeComp(view, entity))
85
88
  })
86
- // event_manager.subscribe(EventTypes.ComponentAdded, InputComp, ({ entity, component }) => {
87
- // const { bg, size = 48, fill } = component.props
88
- // const view = new Input({ bg, textStyle: { fontSize: size, fill } })
89
- // component.node = entity.assign(new NodeComp(view, entity))
90
- // })
89
+ event_manager.subscribe(EventTypes.ComponentAdded, InputComp, ({ entity, component }) => {
90
+ const { bg, size = 48 } = component.props
91
+ const view = new Input({ bg, textStyle: { fontSize: size, fill: { color: Color4B(255, 255, 255, 255) } } })
92
+ component.node = entity.assign(new NodeComp(view, entity))
93
+ })
91
94
  event_manager.subscribe(EventTypes.ComponentAdded, LabelComp, ({ entity, component }) => {
92
95
  // console.log('ComponentAddedEvent LabelComp', component)
93
96
  const node = new Text()
@@ -107,7 +110,7 @@ export class GUISystem implements System {
107
110
  }
108
111
  })
109
112
  event_manager.subscribe(EventTypes.ComponentAdded, LabelShadowComp, ({ entity, component }) => {
110
- const { color, blur, offset } = component.props
113
+ const { color, blur } = component.props
111
114
  const node = entity.getComponent(NodeComp)
112
115
  if (node.instance instanceof Text) {
113
116
  node.instance.style.dropShadow = { color, blur, alpha: 1, angle: 0, distance: 0 }
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from 'pixi-action-ease'
2
1
  export * from 'pixi.js'
3
2
  export * from './app'
4
3
  export * from './base'
@@ -18,4 +17,3 @@ export * from './render/RenderComponent'
18
17
  export * from './render/RenderSystem'
19
18
  export * from './richtext'
20
19
  export * from './spine'
21
-
@@ -8,8 +8,8 @@ export class Touch {
8
8
  this.event = event
9
9
  }
10
10
 
11
- getLocation() {
12
- return this.event.global
11
+ getLocation(): ReturnType<typeof Vec2> {
12
+ return Vec2(this.event.global)
13
13
  }
14
14
  getLocationX() {
15
15
  return this.event.globalX
@@ -17,7 +17,7 @@ export class Touch {
17
17
  getLocationY() {
18
18
  return this.event.globalY
19
19
  }
20
- getDelta() {
20
+ getDelta(): ReturnType<typeof Vec2> {
21
21
  return Vec2(this.event.movementX, this.event.movementY)
22
22
  }
23
23
  getDeltaX() {
@@ -1,6 +1,6 @@
1
1
  import { Graphics, Sprite, Texture } from 'pixi.js'
2
2
 
3
- import { Color4B, Vec2 } from '..'
3
+ import { BaseComponentProps, Color4B, Vec2 } from '..'
4
4
  import { ComponentX } from '../components/BaseComponent'
5
5
  import { LoadingBarMode } from '../core/LoadingBar'
6
6
  import { SpriteTypes } from './RenderSystem'
@@ -9,7 +9,7 @@ export class NodeRender extends ComponentX {
9
9
  nodeName?: string
10
10
  }
11
11
 
12
- interface SpriteRenderProps {
12
+ interface SpriteRenderProps extends BaseComponentProps<SpriteRender> {
13
13
  spriteFrame: string
14
14
  type?: SpriteTypes
15
15
  fillType?: LoadingBarMode
@@ -18,7 +18,7 @@ interface SpriteRenderProps {
18
18
  // loadingBar: LoadingBar
19
19
  }
20
20
 
21
- export class SpriteRender extends ComponentX<SpriteRenderProps & { $ref?: SpriteRender }, Sprite> {
21
+ export class SpriteRender extends ComponentX<SpriteRenderProps, Sprite> {
22
22
  // protected _spriteFrame: string
23
23
  // set fillStart(val: number) {
24
24
  // if (this.node.instance instanceof cc.ProgressTimer) {
@@ -60,16 +60,16 @@ enum PointType {
60
60
  Circle,
61
61
  Rect,
62
62
  }
63
- interface GraphicsRenderProps {
63
+ interface GraphicsRenderProps extends BaseComponentProps<GraphicsRender> {
64
64
  lineWidth?: number
65
65
  strokeColor?: Color4B
66
66
  fillColor?: Color4B
67
67
  }
68
- export class GraphicsRender extends ComponentX<GraphicsRenderProps & { $ref?: GraphicsRender }, Graphics> {
69
- drawPoint(position: Vec2, pointSize: Float, color: Color4B, pointType = PointType.Rect) {}
68
+ export class GraphicsRender extends ComponentX<GraphicsRenderProps, Graphics> {
69
+ drawPoint(position: Vec2, pointSize: Float, color: Color4B, pointType = PointType.Rect) { }
70
70
  // drawPoints(points: Vec2[], color: Color4B) {
71
71
  // }
72
- drawLine(origin: Vec2, destination: Vec2, color: Color4B, thickness: Float) {}
72
+ drawLine(origin: Vec2, destination: Vec2, color: Color4B, thickness: Float) { }
73
73
  drawRect(origin: Vec2, destination: Vec2, color: Color4B) {
74
74
  const { x, y } = origin
75
75
  const width = destination.x - x
@@ -77,7 +77,7 @@ export class GraphicsRender extends ComponentX<GraphicsRenderProps & { $ref?: Gr
77
77
  this.node.instance.rect(x, y, width, height)
78
78
  this.node.instance.fill(color)
79
79
  }
80
- drawSolidRect(origin: Vec2, destination: Vec2, color: Color4B) {}
80
+ drawSolidRect(origin: Vec2, destination: Vec2, color: Color4B) { }
81
81
  drawCircle(
82
82
  center: Vec2,
83
83
  radius: Float,
@@ -93,17 +93,17 @@ export class GraphicsRender extends ComponentX<GraphicsRenderProps & { $ref?: Gr
93
93
  this.node.instance.circle(x, y, radius)
94
94
  this.node.instance.fill(color)
95
95
  }
96
- drawSolidCircle(origin: Vec2, destination: Vec2, color: Color4B) {}
97
- drawQuadBezier(origin: Vec2, destination: Vec2, color: Color4B) {}
98
- drawCubicBezier(origin: Vec2, destination: Vec2, color: Color4B) {}
99
- drawCardinalSpline(points: Vec2[], color: Color4B) {}
100
- drawCatmullRom(points: Vec2[], color: Color4B) {}
96
+ drawSolidCircle(origin: Vec2, destination: Vec2, color: Color4B) { }
97
+ drawQuadBezier(origin: Vec2, destination: Vec2, color: Color4B) { }
98
+ drawCubicBezier(origin: Vec2, destination: Vec2, color: Color4B) { }
99
+ drawCardinalSpline(points: Vec2[], color: Color4B) { }
100
+ drawCatmullRom(points: Vec2[], color: Color4B) { }
101
101
  drawPoly(points: Vec2[], color?: Color4B, thickness?: Float) {
102
102
  this.node.instance.poly(points, true)
103
103
  this.node.instance.fill(color || this.props.fillColor)
104
104
  }
105
- drawSolidPoly(points: Vec2[], color: Color4B) {}
106
- drawDot(points: Vec2[], color: Color4B) {}
105
+ drawSolidPoly(points: Vec2[], color: Color4B) { }
106
+ drawDot(points: Vec2[], color: Color4B) { }
107
107
  drawSegment(from: Vec2, to: Vec2, thickness?: Float, color?: Color4B) {
108
108
  this.node.instance.moveTo(from.x, from.y)
109
109
  this.node.instance.lineTo(to.x, to.y)
@@ -124,9 +124,9 @@ export class GraphicsRender extends ComponentX<GraphicsRenderProps & { $ref?: Gr
124
124
  }
125
125
  }
126
126
 
127
- interface MaskRenderProps {
127
+ interface MaskRenderProps extends BaseComponentProps<MaskRender>{
128
128
  type?: number
129
129
  segments?: number
130
130
  inverted?: boolean
131
131
  }
132
- export class MaskRender extends ComponentX<MaskRenderProps> {}
132
+ export class MaskRender extends ComponentX<MaskRenderProps> { }
@@ -1,25 +1,29 @@
1
1
  import TaggedText from 'pixi-tagged-text-plus'
2
+ import { BaseComponentProps } from '..'
2
3
  import { ComponentX } from '../components/BaseComponent'
3
- import { generateStringFromStyledElements, generateStylesFromStyledElements, parseFontString, transformToStyledElements } from './html-text-parser'
4
+ import {
5
+ generateStringFromStyledElements,
6
+ generateStylesFromStyledElements,
7
+ parseFontString,
8
+ transformToStyledElements,
9
+ } from './html-text-parser'
4
10
 
5
- interface RichTextCompProps {
11
+ interface RichTextCompProps extends BaseComponentProps<RichTextComp> {
6
12
  font?: string
7
13
  string?: string
8
14
  size?: number
9
15
  }
10
16
 
11
17
  export class RichTextComp extends ComponentX<RichTextCompProps, TaggedText> {
12
-
13
18
  get string() {
14
19
  return this.props.string
15
20
  }
16
21
 
17
-
18
22
  set string(val: string) {
19
23
  this.props.string = val
20
24
  if (!this.node) return
21
- const jObj = parseFontString(val);
22
- const styledOutput = transformToStyledElements(jObj);
25
+ const jObj = parseFontString(val)
26
+ const styledOutput = transformToStyledElements(jObj)
23
27
  const newText = generateStringFromStyledElements(styledOutput)
24
28
  const styles = generateStylesFromStyledElements(styledOutput)
25
29
  // console.log(styledOutput)
@@ -1,4 +1,6 @@
1
- import { ComponentX } from "../components/BaseComponent"
1
+ import { BaseComponentProps } from '..'
2
+ import { ComponentX } from '../components/BaseComponent'
3
+ import { Spine } from './lib'
2
4
 
3
5
  interface SpineData {
4
6
  atlas: string
@@ -6,13 +8,11 @@ interface SpineData {
6
8
  texture?: string
7
9
  }
8
10
 
9
- interface SpineSkeletonProps {
11
+ interface SpineSkeletonProps extends BaseComponentProps<SpineSkeleton> {
10
12
  data: SpineData
11
13
  skin?: string
12
14
  animation?: string
13
15
  timeScale?: number
14
16
  loop?: boolean
15
17
  }
16
- export class SpineSkeleton extends ComponentX<SpineSkeletonProps> {
17
-
18
- }
18
+ export class SpineSkeleton extends ComponentX<SpineSkeletonProps, Spine> {}