lyb-pixi-js 1.1.11 → 1.1.13

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 (62) hide show
  1. package/Components/Base/LibPixiBitText.d.ts +20 -0
  2. package/Components/Base/LibPixiBitText.js +26 -0
  3. package/Components/Base/LibPixiContainer.d.ts +22 -0
  4. package/Components/Base/LibPixiContainer.js +51 -0
  5. package/Components/Base/LibPixiParticleMove.d.ts +39 -0
  6. package/Components/Base/LibPixiParticleMove.js +100 -0
  7. package/Components/Base/LibPixiRectBgColor.d.ts +45 -0
  8. package/Components/Base/LibPixiRectBgColor.js +98 -0
  9. package/Components/Base/LibPixiSpine.d.ts +57 -0
  10. package/Components/Base/LibPixiSpine.js +122 -0
  11. package/Components/Base/LibPixiText.d.ts +37 -0
  12. package/Components/Base/LibPixiText.js +32 -0
  13. package/Components/Custom/LibPixiButtonHover.d.ts +32 -0
  14. package/Components/Custom/LibPixiButtonHover.js +44 -0
  15. package/Components/Custom/LibPixiCloseBtn.d.ts +14 -0
  16. package/Components/Custom/LibPixiCloseBtn.js +35 -0
  17. package/Components/Custom/LibPixiDrawer.d.ts +16 -0
  18. package/Components/Custom/LibPixiDrawer.js +59 -0
  19. package/Components/Custom/LibPixiPerforMon.d.ts +31 -0
  20. package/Components/Custom/LibPixiPerforMon.js +107 -0
  21. package/Components/Custom/LibPixiProgress.d.ts +29 -0
  22. package/Components/Custom/LibPixiProgress.js +36 -0
  23. package/Components/Custom/LibPixiScrollContainer.d.ts +57 -0
  24. package/Components/Custom/LibPixiScrollContainer.js +166 -0
  25. package/Components/Custom/LibPixiScrollNum.d.ts +62 -0
  26. package/Components/Custom/LibPixiScrollNum.js +146 -0
  27. package/Components/Custom/LibPixiSlider.d.ts +45 -0
  28. package/Components/Custom/LibPixiSlider.js +111 -0
  29. package/Components/Custom/LibPixiSubAddMinMax.d.ts +49 -0
  30. package/Components/Custom/LibPixiSubAddMinMax.js +76 -0
  31. package/Components/Custom/LibPixiTable.d.ts +52 -0
  32. package/Components/Custom/LibPixiTable.js +70 -0
  33. package/Utils/LibPixiAudio.d.ts +55 -0
  34. package/Utils/LibPixiAudio.js +172 -0
  35. package/Utils/LibPixiCreateNineGrid.d.ts +15 -0
  36. package/Utils/LibPixiCreateNineGrid.js +19 -0
  37. package/Utils/LibPixiEvent.d.ts +9 -0
  38. package/Utils/LibPixiEvent.js +22 -0
  39. package/Utils/LibPixiEventControlled.d.ts +8 -0
  40. package/Utils/LibPixiEventControlled.js +21 -0
  41. package/Utils/LibPixiFilter.d.ts +9 -0
  42. package/Utils/LibPixiFilter.js +30 -0
  43. package/Utils/LibPixiIntervalTrigger.d.ts +6 -0
  44. package/Utils/LibPixiIntervalTrigger.js +33 -0
  45. package/Utils/LibPixiOutsideClick.d.ts +8 -0
  46. package/Utils/LibPixiOutsideClick.js +22 -0
  47. package/Utils/LibPixiOverflowHidden.d.ts +6 -0
  48. package/Utils/LibPixiOverflowHidden.js +14 -0
  49. package/Utils/LibPixiPromiseTickerTimeout.d.ts +6 -0
  50. package/Utils/LibPixiPromiseTickerTimeout.js +22 -0
  51. package/Utils/LibPixiScaleContainer.d.ts +8 -0
  52. package/Utils/LibPixiScaleContainer.js +14 -0
  53. package/Utils/LibPixiShadow.d.ts +17 -0
  54. package/Utils/LibPixiShadow.js +18 -0
  55. package/Utils/LibPixiTickerTimeout.d.ts +6 -0
  56. package/Utils/LibPixiTickerTimeout.js +28 -0
  57. package/index.d.ts +1 -0
  58. package/index.js +2 -0
  59. package/libPixiJs.d.ts +163 -0
  60. package/libPixiJs.js +174 -0
  61. package/lyb-pixi.js +1263 -0
  62. package/package.json +1 -1
@@ -0,0 +1,20 @@
1
+ import { BitmapText } from "pixi.js";
2
+ /** @description 自定义位图文本
3
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiBitText-位图
4
+ */
5
+ export declare class LibPixiBitText {
6
+ /** 字体名称 */
7
+ private _fontName;
8
+ private _defaultFontSize?;
9
+ /**
10
+ * @param fontName 字体名称
11
+ * @param defaultFontSize 默认字体大小
12
+ */
13
+ constructor(fontName: string, defaultFontSize?: number);
14
+ /** @description 创建位图文本
15
+ * @param text 文本内容
16
+ * @param fontSize 字体大小,不填则使用默认大小
17
+ * @returns 位图实例
18
+ */
19
+ createText(text: string | number, fontSize?: number): BitmapText;
20
+ }
@@ -0,0 +1,26 @@
1
+ import { BitmapText } from "pixi.js";
2
+ /** @description 自定义位图文本
3
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiBitText-位图
4
+ */
5
+ export class LibPixiBitText {
6
+ /**
7
+ * @param fontName 字体名称
8
+ * @param defaultFontSize 默认字体大小
9
+ */
10
+ constructor(fontName, defaultFontSize) {
11
+ this._fontName = fontName;
12
+ this._defaultFontSize = defaultFontSize;
13
+ }
14
+ /** @description 创建位图文本
15
+ * @param text 文本内容
16
+ * @param fontSize 字体大小,不填则使用默认大小
17
+ * @returns 位图实例
18
+ */
19
+ createText(text, fontSize) {
20
+ const bitMapText = new BitmapText(text.toString(), {
21
+ fontName: this._fontName,
22
+ fontSize: this._defaultFontSize || fontSize,
23
+ });
24
+ return bitMapText;
25
+ }
26
+ }
@@ -0,0 +1,22 @@
1
+ import { Container } from "pixi.js";
2
+ /** @description 自定义容器大小及背景色
3
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiContainer-容器
4
+ */
5
+ export declare class LibPixiContainer extends Container {
6
+ /** 填充容器 */
7
+ private _fill?;
8
+ /** 背景色填充 */
9
+ private _bgColorFill?;
10
+ /**
11
+ * @param width 容器宽度
12
+ * @param height 容器高度
13
+ * @param bgColor 背景色
14
+ * @param overHidden 是否溢出裁剪
15
+ */
16
+ constructor(width: number, height: number, bgColor?: string, overHidden?: boolean);
17
+ /** @description 设置容器大小
18
+ * @param width 容器宽度
19
+ * @param height 容器高度
20
+ */
21
+ setSize(width: number, height: number): void;
22
+ }
@@ -0,0 +1,51 @@
1
+ import { Container, Graphics, Sprite } from "pixi.js";
2
+ import { LibPixiRectBgColor } from './LibPixiRectBgColor';
3
+ /** @description 自定义容器大小及背景色
4
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiContainer-容器
5
+ */
6
+ export class LibPixiContainer extends Container {
7
+ /**
8
+ * @param width 容器宽度
9
+ * @param height 容器高度
10
+ * @param bgColor 背景色
11
+ * @param overHidden 是否溢出裁剪
12
+ */
13
+ constructor(width, height, bgColor, overHidden) {
14
+ super();
15
+ if (overHidden) {
16
+ const mask = new Graphics();
17
+ mask.beginFill(0xffffff);
18
+ mask.drawRect(0, 0, width, height);
19
+ mask.endFill();
20
+ this.addChild(mask);
21
+ this.mask = mask;
22
+ }
23
+ if (bgColor) {
24
+ this._bgColorFill = new LibPixiRectBgColor({
25
+ width,
26
+ height,
27
+ bgColor,
28
+ });
29
+ this.addChild(this._bgColorFill);
30
+ }
31
+ else {
32
+ this._fill = new Sprite();
33
+ this._fill.width = width;
34
+ this._fill.height = height;
35
+ this.addChild(this._fill);
36
+ }
37
+ }
38
+ /** @description 设置容器大小
39
+ * @param width 容器宽度
40
+ * @param height 容器高度
41
+ */
42
+ setSize(width, height) {
43
+ if (this._fill) {
44
+ this._fill.width = width;
45
+ this._fill.height = height;
46
+ }
47
+ if (this._bgColorFill) {
48
+ this._bgColorFill.renderBg(width, height);
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,39 @@
1
+ import { Container } from "pixi.js";
2
+ import { type EmitterConfigV3 } from "@pixi/particle-emitter";
3
+ export interface LibPixiParticleMoveParams {
4
+ /** 粒子JSON资源 */
5
+ json: EmitterConfigV3;
6
+ /** 运动时长 */
7
+ duration: number;
8
+ /** 粒子开始位置 */
9
+ start: {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ /** 粒子控制点 */
14
+ control: {
15
+ x: number;
16
+ y: number;
17
+ }[];
18
+ /** 粒子结束点 */
19
+ end: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ /** 运动曲线 */
24
+ ease?: gsap.EaseString;
25
+ /** 是否显示控制点,调试使用 */
26
+ showControl?: boolean;
27
+ /** 是否循环,调试使用 */
28
+ loop?: boolean;
29
+ }
30
+ /** @description 利用贝塞尔曲线实现粒子移动
31
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiParticleMove-粒子容器
32
+ */
33
+ export declare class LibPixiParticleMove extends Container {
34
+ private _particleContainer;
35
+ constructor(params: LibPixiParticleMoveParams);
36
+ private _createBezierPoints;
37
+ private _multiPointBezier;
38
+ private _binomial;
39
+ }
@@ -0,0 +1,100 @@
1
+ import { Container, ParticleContainer, Ticker } from "pixi.js";
2
+ import { Emitter } from "@pixi/particle-emitter";
3
+ import gsap from "gsap";
4
+ import { LibPixiText } from "./LibPixiText";
5
+ /** @description 利用贝塞尔曲线实现粒子移动
6
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiParticleMove-粒子容器
7
+ */
8
+ export class LibPixiParticleMove extends Container {
9
+ constructor(params) {
10
+ super();
11
+ const { start, control, end, json, duration, ease = "power1.out", showControl = false, loop = false, } = params;
12
+ this._particleContainer = new ParticleContainer();
13
+ this.addChild(this._particleContainer);
14
+ // 初始化粒子发射器
15
+ const flyParticle = new Emitter(this._particleContainer, json);
16
+ // 创建贝塞尔曲线的路径
17
+ const path = this._createBezierPoints([start, ...control, end], 100, showControl);
18
+ // 用来控制路径动画的对象
19
+ const flyObj = { pathThrough: 0 };
20
+ gsap.to(flyObj, {
21
+ duration,
22
+ pathThrough: path.length - 1,
23
+ repeat: loop ? -1 : 0,
24
+ ease,
25
+ onStart: () => {
26
+ flyParticle.emit = true;
27
+ },
28
+ onUpdate: () => {
29
+ const i = Math.floor(flyObj.pathThrough);
30
+ const p = path[i];
31
+ flyParticle.updateOwnerPos(p.x, p.y);
32
+ },
33
+ onComplete: () => {
34
+ gsap.to(this, {
35
+ alpha: 0,
36
+ duration: 0.5,
37
+ onComplete: () => {
38
+ flyParticle.emit = false;
39
+ ticker.destroy();
40
+ this.removeFromParent();
41
+ },
42
+ });
43
+ },
44
+ });
45
+ const ticker = new Ticker();
46
+ ticker.add(() => {
47
+ flyParticle.update(1 / 75);
48
+ });
49
+ ticker.start();
50
+ }
51
+ _createBezierPoints(anchorPoints, pointsAmount, showControl) {
52
+ const points = [];
53
+ // 渲染控制点
54
+ if (showControl) {
55
+ anchorPoints.forEach((item, index) => {
56
+ //创建一个小圆点
57
+ const text = new LibPixiText({
58
+ text: index + 1,
59
+ fontSize: 16,
60
+ });
61
+ text.position.set(item.x, item.y);
62
+ this.addChild(text);
63
+ });
64
+ }
65
+ // 计算并存储贝塞尔曲线上的点
66
+ for (let i = 0; i < pointsAmount; i++) {
67
+ const point = this._multiPointBezier(anchorPoints, i / pointsAmount);
68
+ points.push(point);
69
+ }
70
+ return points;
71
+ }
72
+ _multiPointBezier(points, t) {
73
+ const len = points.length;
74
+ let x = 0, y = 0;
75
+ // 预计算组合数
76
+ const binomials = [];
77
+ for (let i = 0; i < len; i++) {
78
+ binomials[i] = this._binomial(len - 1, i);
79
+ }
80
+ // 计算贝塞尔曲线上的点
81
+ for (let i = 0; i < len; i++) {
82
+ const point = points[i];
83
+ const binom = binomials[i];
84
+ const factorT = Math.pow(t, i);
85
+ const factor1MinusT = Math.pow(1 - t, len - 1 - i);
86
+ x += point.x * factor1MinusT * factorT * binom;
87
+ y += point.y * factor1MinusT * factorT * binom;
88
+ }
89
+ return { x, y };
90
+ }
91
+ _binomial(n, k) {
92
+ if (k === 0 || k === n)
93
+ return 1;
94
+ let res = 1;
95
+ for (let i = 1; i <= k; i++) {
96
+ res = (res * (n - i + 1)) / i;
97
+ }
98
+ return res;
99
+ }
100
+ }
@@ -0,0 +1,45 @@
1
+ import { Graphics } from "pixi.js";
2
+ export interface LibPixiRectBgColorParams {
3
+ /** 宽度 */
4
+ width?: number;
5
+ /** 高度 */
6
+ height?: number;
7
+ /** 背景颜色 */
8
+ bgColor?: string | number;
9
+ /** x轴偏移 */
10
+ x?: number;
11
+ /** y轴偏移 */
12
+ y?: number;
13
+ /** 透明度 */
14
+ alpha?: number;
15
+ /** 圆角半径 */
16
+ radius?: number | number[];
17
+ /** 边框宽度 */
18
+ borderWidth?: number;
19
+ /** 边框颜色 */
20
+ borderColor?: string;
21
+ /** 是否启用变色功能 */
22
+ enableTint?: boolean;
23
+ }
24
+ /** @description 自定义矩形背景色
25
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiRectBgColor-矩形
26
+ */
27
+ export declare class LibPixiRectBgColor extends Graphics {
28
+ /** 圆边大小 */
29
+ private radius;
30
+ /** 启用着色 */
31
+ private enableTint;
32
+ /** 背景颜色 */
33
+ private bgColor;
34
+ /** 边框宽度 */
35
+ private borderWidth;
36
+ /** 边框颜色 */
37
+ private borderColor;
38
+ /** 背景色 */
39
+ private bgAlpha;
40
+ constructor(options: LibPixiRectBgColorParams);
41
+ /** @description 重新绘制并添加颜色 */
42
+ updateColor(tint: string): void;
43
+ /** @description 更新宽度 */
44
+ renderBg(width: number, height: number): void;
45
+ }
@@ -0,0 +1,98 @@
1
+ import { Graphics } from "pixi.js";
2
+ import gsap from "gsap";
3
+ /** @description 自定义矩形背景色
4
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiRectBgColor-矩形
5
+ */
6
+ export class LibPixiRectBgColor extends Graphics {
7
+ constructor(options) {
8
+ super();
9
+ /** 圆边大小 */
10
+ this.radius = 0;
11
+ /** 启用着色 */
12
+ this.enableTint = true;
13
+ /** 背景颜色 */
14
+ this.bgColor = "#fff";
15
+ /** 边框宽度 */
16
+ this.borderWidth = 0;
17
+ /** 边框颜色 */
18
+ this.borderColor = "black";
19
+ /** 背景色 */
20
+ this.bgAlpha = 1;
21
+ const { x = 0, y = 0, width = 0, height = 0, bgColor = "#fff", alpha = 1, radius = 0, borderWidth = 0, borderColor = "black", enableTint = true, } = options;
22
+ this.x = x;
23
+ this.y = y;
24
+ this.bgAlpha = alpha;
25
+ this.radius = radius;
26
+ this.enableTint = enableTint;
27
+ this.bgColor = bgColor;
28
+ this.borderWidth = borderWidth;
29
+ this.borderColor = borderColor;
30
+ this.renderBg(width, height);
31
+ }
32
+ /** @description 重新绘制并添加颜色 */
33
+ updateColor(tint) {
34
+ gsap.to(this, { tint, duration: 0.25 });
35
+ }
36
+ /** @description 更新宽度 */
37
+ renderBg(width, height) {
38
+ this.clear();
39
+ if (this.enableTint) {
40
+ this.beginFill("#fff", this.bgAlpha);
41
+ this.tint = this.bgColor;
42
+ }
43
+ else {
44
+ this.beginFill(this.bgColor, this.bgAlpha);
45
+ this.borderWidth && this.lineStyle(this.borderWidth, this.borderColor, 1);
46
+ }
47
+ this.borderWidth && this.lineStyle(this.borderWidth, this.borderColor, 1);
48
+ if (this.radius !== 0) {
49
+ if (typeof this.radius === "number") {
50
+ this.drawRoundedRect(0, 0, width, height, this.radius);
51
+ }
52
+ else {
53
+ // 绘制顶部边
54
+ this.moveTo(0 + this.radius[0], 0);
55
+ this.lineTo(0 + width - this.radius[1], 0);
56
+ // 绘制右上角的圆角
57
+ if (this.radius[1] > 0) {
58
+ this.arcTo(0 + width, 0, 0 + width, 0 + this.radius[1], this.radius[1]);
59
+ }
60
+ else {
61
+ this.lineTo(0 + width, 0);
62
+ }
63
+ // 绘制右侧边
64
+ this.lineTo(0 + width, 0 + height - this.radius[2]);
65
+ // 绘制右下角的圆角
66
+ if (this.radius[2] > 0) {
67
+ this.arcTo(0 + width, 0 + height, 0 + width - this.radius[2], 0 + height, this.radius[2]);
68
+ }
69
+ else {
70
+ this.lineTo(0 + width, 0 + height);
71
+ }
72
+ // 绘制底部边
73
+ this.lineTo(0 + this.radius[3], 0 + height);
74
+ // 绘制左下角的圆角
75
+ if (this.radius[3] > 0) {
76
+ this.arcTo(0, 0 + height, 0, 0 + height - this.radius[3], this.radius[3]);
77
+ }
78
+ else {
79
+ this.lineTo(0, 0 + height);
80
+ }
81
+ // 绘制左侧边
82
+ this.lineTo(0, 0 + this.radius[0]);
83
+ // 绘制左上角的圆角
84
+ if (this.radius[0] > 0) {
85
+ this.arcTo(0, 0, 0 + this.radius[0], 0, this.radius[0]);
86
+ }
87
+ else {
88
+ this.lineTo(0, 0);
89
+ }
90
+ this.closePath();
91
+ }
92
+ }
93
+ else {
94
+ this.drawRect(0, 0, width, height);
95
+ }
96
+ this.endFill();
97
+ }
98
+ }
@@ -0,0 +1,57 @@
1
+ import { type Container } from "pixi.js";
2
+ import { Spine } from "@pixi-spine/runtime-3.8";
3
+ export interface OnUpdateParams {
4
+ x: number;
5
+ y: number;
6
+ rotate: number;
7
+ scaleX: number;
8
+ scaleY: number;
9
+ }
10
+ export interface LibPixiSpineParams {
11
+ /** 默认是否可见 */
12
+ visible?: boolean;
13
+ /** 挂点列表 */
14
+ followPointList?: {
15
+ /** 挂点名称 */
16
+ boneName: string;
17
+ /** 跟随的精灵或容器 */
18
+ follow: Container;
19
+ /** 是否启用角度 */
20
+ angleFollow?: boolean;
21
+ /** 是否启用缩放 */
22
+ scaleFollow?: boolean;
23
+ /** 更新回调,不传则接受内置挂点更新 */
24
+ onUpdate?: (config: OnUpdateParams) => void;
25
+ }[];
26
+ }
27
+ /** @description 自定义 Spine 动画
28
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSpine-动画
29
+ */
30
+ export declare class LibPixiSpine extends Spine {
31
+ /** 挂点 */
32
+ private _followDots;
33
+ /** 是否已开始 */
34
+ private _isStart;
35
+ /** spine更新函数 */
36
+ private _loopFn;
37
+ constructor(spineNameOrTexture: string | any, params?: LibPixiSpineParams);
38
+ /** @description 设置动画
39
+ * @param animationName 动画名称
40
+ * @param loop 是否循环播放
41
+ */
42
+ setAnimation(animationName?: string, loop?: boolean): Promise<void>;
43
+ /** @description 添加动画
44
+ * @param animationName 动画名称
45
+ * @param loop 是否循环播放
46
+ * @param delay 延迟播放时间
47
+ */
48
+ addAnimation(animationName?: string, loop?: boolean, delay?: number): Promise<void>;
49
+ /** @description 改变骨骼数据 */
50
+ setSkin(skinName: string): void;
51
+ /** @description 销毁动画及挂点 */
52
+ destroyAll(): void;
53
+ /** @description 更新渲染 */
54
+ private _loop;
55
+ /** @description 更新挂点 */
56
+ private _updateFollowPoint;
57
+ }
@@ -0,0 +1,122 @@
1
+ import { Assets, Ticker } from "pixi.js";
2
+ import { Spine } from "@pixi-spine/runtime-3.8";
3
+ import gsap from "gsap";
4
+ /** @description 自定义 Spine 动画
5
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSpine-动画
6
+ */
7
+ export class LibPixiSpine extends Spine {
8
+ constructor(spineNameOrTexture, params) {
9
+ const { followPointList, visible = false } = params || {};
10
+ let spineData;
11
+ if (typeof spineNameOrTexture === "string") {
12
+ spineData = Assets.get(spineNameOrTexture).spineData;
13
+ }
14
+ else {
15
+ spineData = spineNameOrTexture.spineData;
16
+ }
17
+ super(spineData);
18
+ /** 挂点 */
19
+ this._followDots = [];
20
+ /** 是否已开始 */
21
+ this._isStart = false;
22
+ this.visible = visible;
23
+ this.autoUpdate = false;
24
+ //如果存在挂点
25
+ if (followPointList === null || followPointList === void 0 ? void 0 : followPointList.length) {
26
+ followPointList === null || followPointList === void 0 ? void 0 : followPointList.forEach((item) => {
27
+ item.follow.alpha = 0;
28
+ this._followDots.push({
29
+ point: this.skeleton.findBone(item.boneName),
30
+ follow: item.follow,
31
+ onUpdate: item.onUpdate,
32
+ angleFollow: item.angleFollow || false,
33
+ scaleFollow: item.scaleFollow || true,
34
+ });
35
+ });
36
+ }
37
+ this._loopFn = this._loop.bind(this);
38
+ Ticker.system.add(this._loopFn);
39
+ }
40
+ /** @description 设置动画
41
+ * @param animationName 动画名称
42
+ * @param loop 是否循环播放
43
+ */
44
+ setAnimation(animationName = "animation", loop = false) {
45
+ return new Promise((resolve) => {
46
+ this.visible = true;
47
+ this.state.setAnimation(0, animationName, loop).listener = {
48
+ complete: () => {
49
+ resolve();
50
+ },
51
+ };
52
+ });
53
+ }
54
+ /** @description 添加动画
55
+ * @param animationName 动画名称
56
+ * @param loop 是否循环播放
57
+ * @param delay 延迟播放时间
58
+ */
59
+ addAnimation(animationName = "animation", loop = false, delay = 0) {
60
+ return new Promise((resolve) => {
61
+ this.visible = true;
62
+ this.state.addAnimation(0, animationName, loop, delay).listener = {
63
+ complete: () => {
64
+ resolve();
65
+ },
66
+ };
67
+ });
68
+ }
69
+ /** @description 改变骨骼数据 */
70
+ setSkin(skinName) {
71
+ this.skeleton.setSkinByName(skinName);
72
+ }
73
+ /** @description 销毁动画及挂点 */
74
+ destroyAll() {
75
+ Ticker.system.remove(this._loopFn);
76
+ this.destroy();
77
+ }
78
+ /** @description 更新渲染 */
79
+ _loop() {
80
+ this.update(Ticker.system.deltaMS / 1000);
81
+ this._updateFollowPoint();
82
+ }
83
+ /** @description 更新挂点 */
84
+ _updateFollowPoint() {
85
+ if (this._followDots.length === 0)
86
+ return;
87
+ this._followDots.forEach((item) => {
88
+ const { worldX: x, worldY: y } = item.point;
89
+ const rotate = item.point.getWorldRotationX() * (Math.PI / 180);
90
+ const scaleX = item.point.getWorldScaleX();
91
+ const scaleY = item.point.getWorldScaleY();
92
+ if (item.onUpdate) {
93
+ item.onUpdate({
94
+ x,
95
+ y,
96
+ rotate,
97
+ scaleX,
98
+ scaleY,
99
+ });
100
+ }
101
+ else {
102
+ if (item.angleFollow) {
103
+ item.follow.rotation = rotate;
104
+ }
105
+ if (item.scaleFollow) {
106
+ item.follow.scale.set(scaleX, scaleY);
107
+ }
108
+ item.follow.position.set(x + 1920 / 2 - item.follow.width / 2, y + 1080 / 2 - item.follow.height / 2);
109
+ }
110
+ });
111
+ if (!this._isStart) {
112
+ this._isStart = true;
113
+ this._followDots.forEach((item) => {
114
+ gsap.to(item.follow, {
115
+ alpha: 1,
116
+ duration: 0.25,
117
+ delay: 0.15,
118
+ });
119
+ });
120
+ }
121
+ }
122
+ }
@@ -0,0 +1,37 @@
1
+ import { Text, type TextStyleAlign, type TextStyleFontWeight } from "pixi.js";
2
+ export interface LibPixiTextParams {
3
+ /** 文本内容 */
4
+ text: string | number;
5
+ /** 字体大小 */
6
+ fontSize?: number;
7
+ /** 字体颜色 */
8
+ fontColor?: any;
9
+ /** 是否描边 */
10
+ stroke?: boolean;
11
+ /** 描边颜色 */
12
+ strokeColor?: string | number;
13
+ /** 描边宽度 */
14
+ strokeThickness?: number;
15
+ /** 字体样式 */
16
+ fontFamily?: string;
17
+ /** 字体粗细 */
18
+ fontWeight?: TextStyleFontWeight;
19
+ /** 是否换行 */
20
+ wordWrap?: boolean;
21
+ /** 换行宽度 */
22
+ wordWrapWidth?: number;
23
+ /** 行高 */
24
+ lineHeight?: number;
25
+ /** 对齐方式 */
26
+ align?: TextStyleAlign;
27
+ /** 缩进,单位为字数 */
28
+ indent?: number;
29
+ /** 阴影-颜色 角度 模糊度 阴影距离 */
30
+ shadow?: [string, number, number, number];
31
+ }
32
+ /** @description 自定义文本类
33
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiText-文本
34
+ */
35
+ export declare class LibPixiText extends Text {
36
+ constructor(options: LibPixiTextParams);
37
+ }
@@ -0,0 +1,32 @@
1
+ import { Text, TextStyle } from "pixi.js";
2
+ /** @description 自定义文本类
3
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiText-文本
4
+ */
5
+ export class LibPixiText extends Text {
6
+ constructor(options) {
7
+ const { text, fontSize = 36, fontColor = 0xffffff, stroke, strokeColor, strokeThickness, fontFamily = "MicrosoftYaHei", fontWeight = "normal", wordWrap = false, wordWrapWidth = 100, lineHeight = 1.25, align = "left", indent = 0, shadow, } = options;
8
+ const style = new TextStyle({
9
+ fontSize,
10
+ wordWrap,
11
+ wordWrapWidth,
12
+ fontWeight,
13
+ lineHeight: lineHeight * fontSize,
14
+ breakWords: wordWrap,
15
+ fill: fontColor,
16
+ align,
17
+ fontFamily: fontFamily,
18
+ stroke: stroke ? strokeColor : "transparent",
19
+ strokeThickness: stroke ? strokeThickness : 0,
20
+ lineJoin: "round",
21
+ });
22
+ if (shadow) {
23
+ style.dropShadow = true;
24
+ style.dropShadowColor = shadow[0];
25
+ style.dropShadowAngle = shadow[1] * (Math.PI / 180);
26
+ style.dropShadowBlur = shadow[2];
27
+ style.dropShadowDistance = shadow[3];
28
+ }
29
+ super(text, style);
30
+ this.position.x = indent * fontSize;
31
+ }
32
+ }
@@ -0,0 +1,32 @@
1
+ import { Container, type Texture } from "pixi.js";
2
+ export interface LibPixiButtonHoverParams {
3
+ /** 图标资源 */
4
+ texture: Texture;
5
+ /** 悬浮图标 */
6
+ hoverTexture: Texture;
7
+ /** 染色 */
8
+ tintColor?: string;
9
+ }
10
+ /** @description 悬浮切换材质
11
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiButtonHover-按钮悬浮
12
+ */
13
+ export declare class LibPixiButtonHover extends Container {
14
+ /** 按钮 */
15
+ private _btn;
16
+ /** 默认材质 */
17
+ private _texture;
18
+ /** 悬浮材质 */
19
+ private _hoverTexture;
20
+ /** 染色 */
21
+ private _tintColor?;
22
+ constructor(params: LibPixiButtonHoverParams);
23
+ /** @description 切换材质
24
+ * @param texture 默认材质
25
+ * @param hoverTexture 悬浮材质
26
+ */
27
+ toggleTexture(texture: Texture, hoverTexture: Texture): void;
28
+ /** @description 屏蔽
29
+ * @param status 状态
30
+ */
31
+ setDisabled(status: boolean): void;
32
+ }