lyb-pixi-js 1.10.6 → 1.10.8
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/Components/Custom/LibPixiLabelValue.d.ts +30 -0
- package/Components/Custom/LibPixiLabelValue.js +26 -0
- package/Components/Custom/LibPixiPuzzleBg.d.ts +7 -0
- package/Components/Custom/LibPixiPuzzleBg.js +45 -0
- package/Components/Custom/LibPixiScrollContainerX.d.ts +1 -1
- package/Components/Custom/LibPixiScrollContainerX.js +1 -1
- package/Components/Custom/LibPixiScrollContainerY.d.ts +1 -1
- package/Components/Custom/LibPixiScrollContainerY.js +1 -1
- package/README.md +36 -5
- package/libPixiJs.d.ts +10 -0
- package/libPixiJs.js +10 -0
- package/lyb-pixi.js +2859 -455
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BitmapText, Container, Sprite } from "pixi.js";
|
|
2
|
+
import { LibPixiText } from "../Base/LibPixiText";
|
|
3
|
+
type T = Sprite | LibPixiText | BitmapText;
|
|
4
|
+
interface LabelValueParams {
|
|
5
|
+
/** 描述 */
|
|
6
|
+
label: T;
|
|
7
|
+
/** 值 */
|
|
8
|
+
value: T;
|
|
9
|
+
/** 最大宽度 */
|
|
10
|
+
maxWidth?: number;
|
|
11
|
+
/** 间隔 */
|
|
12
|
+
gap?: number;
|
|
13
|
+
}
|
|
14
|
+
/** @description 自适应宽度的标签和值组件
|
|
15
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
|
|
16
|
+
*/
|
|
17
|
+
export declare class LibPixiLabelValue extends Container {
|
|
18
|
+
/** 描述 */
|
|
19
|
+
private _label;
|
|
20
|
+
/** 值 */
|
|
21
|
+
private _value;
|
|
22
|
+
/** 间隔 */
|
|
23
|
+
private _gap;
|
|
24
|
+
/** 最大宽度 */
|
|
25
|
+
private _maxWidth?;
|
|
26
|
+
constructor(params: LabelValueParams);
|
|
27
|
+
/** @description 更新坐标 */
|
|
28
|
+
updatePosition(): void;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
import { libPixiScaleContainer } from "../../Utils/LibPixiScaleContainer";
|
|
3
|
+
/** @description 自适应宽度的标签和值组件
|
|
4
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
|
|
5
|
+
*/
|
|
6
|
+
export class LibPixiLabelValue extends Container {
|
|
7
|
+
constructor(params) {
|
|
8
|
+
super();
|
|
9
|
+
const { label, value, maxWidth, gap = 0 } = params;
|
|
10
|
+
this._label = label;
|
|
11
|
+
this._value = value;
|
|
12
|
+
this._maxWidth = maxWidth;
|
|
13
|
+
this._gap = gap;
|
|
14
|
+
this.addChild(this._label);
|
|
15
|
+
this._label.anchor.set(1, 0.5);
|
|
16
|
+
this.addChild(this._value);
|
|
17
|
+
this._value.anchor.set(0.5);
|
|
18
|
+
this.updatePosition();
|
|
19
|
+
}
|
|
20
|
+
/** @description 更新坐标 */
|
|
21
|
+
updatePosition() {
|
|
22
|
+
this._label.x = this._label.width * 0.5 - this._value.width * 0.5;
|
|
23
|
+
this._value.x = this._label.width * 0.5 + this._gap;
|
|
24
|
+
this._maxWidth && libPixiScaleContainer(this, this._maxWidth);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { libJsDecimal } from "lyb-js/Math/LibJsDecimal.js";
|
|
2
|
+
import { Assets, Container, Sprite } from "pixi.js";
|
|
3
|
+
/** @description 设计图背景拼接
|
|
4
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPuzzleBg-设计图背景拼接
|
|
5
|
+
*/
|
|
6
|
+
export class LibPixiPuzzleBg extends Container {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.eventMode = "none";
|
|
10
|
+
// 背景
|
|
11
|
+
const bg = new Sprite(Assets.get("preload/bg"));
|
|
12
|
+
this.addChild(bg);
|
|
13
|
+
bg.visible = false;
|
|
14
|
+
//读取配置
|
|
15
|
+
const config = JSON.parse(localStorage.getItem("puzzle_bg_config") || "{}");
|
|
16
|
+
const { alpha, x, y } = config;
|
|
17
|
+
bg.alpha = alpha || 0.25;
|
|
18
|
+
bg.position.set(x || 0, y || 0);
|
|
19
|
+
//监听鼠标空格事件
|
|
20
|
+
document.addEventListener("keydown", (e) => {
|
|
21
|
+
if (e.code === "Space") {
|
|
22
|
+
bg.visible = !bg.visible;
|
|
23
|
+
}
|
|
24
|
+
else if (e.code === "ArrowUp") {
|
|
25
|
+
bg.y -= 2;
|
|
26
|
+
}
|
|
27
|
+
else if (e.code === "ArrowDown") {
|
|
28
|
+
bg.y += 2;
|
|
29
|
+
}
|
|
30
|
+
else if (e.code === "ArrowLeft") {
|
|
31
|
+
bg.x -= 2;
|
|
32
|
+
}
|
|
33
|
+
else if (e.code === "ArrowRight") {
|
|
34
|
+
bg.x += 2;
|
|
35
|
+
}
|
|
36
|
+
if (e.code === "NumpadAdd" && bg.alpha < 1) {
|
|
37
|
+
bg.alpha = libJsDecimal(bg.alpha, 0.1, "+");
|
|
38
|
+
}
|
|
39
|
+
else if (e.code === "NumpadSubtract" && bg.alpha > 0) {
|
|
40
|
+
bg.alpha = libJsDecimal(bg.alpha, 0.1, "-");
|
|
41
|
+
}
|
|
42
|
+
localStorage.setItem("puzzle_bg_config", JSON.stringify({ alpha: bg.alpha, x: bg.x, y: bg.y }));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -13,7 +13,7 @@ export interface LibPixiScrollContainerXParams {
|
|
|
13
13
|
rightMargin?: number;
|
|
14
14
|
}
|
|
15
15
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
16
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X
|
|
16
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
|
|
17
17
|
*/
|
|
18
18
|
export declare class LibPixiScrollContainerX extends LibPixiContainer {
|
|
19
19
|
/** 开始位置 */
|
|
@@ -2,7 +2,7 @@ import { Container, Graphics, Sprite, } from "pixi.js";
|
|
|
2
2
|
import { gsap } from "gsap";
|
|
3
3
|
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
4
4
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
5
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X
|
|
5
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerX-X轴滚动容器
|
|
6
6
|
*/
|
|
7
7
|
export class LibPixiScrollContainerX extends LibPixiContainer {
|
|
8
8
|
constructor(params) {
|
|
@@ -23,7 +23,7 @@ export interface LibPixiScrollContainerYParams {
|
|
|
23
23
|
onScroll?: (y: number) => void;
|
|
24
24
|
}
|
|
25
25
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
26
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y
|
|
26
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
27
27
|
*/
|
|
28
28
|
export declare class LibPixiScrollContainerY extends LibPixiContainer {
|
|
29
29
|
/** 开始位置 */
|
|
@@ -4,7 +4,7 @@ import { libPixiEvent } from "../../Utils/LibPixiEvent";
|
|
|
4
4
|
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
5
5
|
import { LibPixiRectangle } from "../Base/LibPixiRectangle";
|
|
6
6
|
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
7
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y
|
|
7
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScrollContainerY-Y轴滚动容器
|
|
8
8
|
*/
|
|
9
9
|
export class LibPixiScrollContainerY extends LibPixiContainer {
|
|
10
10
|
constructor(params) {
|
package/README.md
CHANGED
|
@@ -112,9 +112,9 @@ app.stage.addChild(box);
|
|
|
112
112
|
|
|
113
113
|
\- [LibPixiProgress-进度条](#LibPixiProgress-进度条)
|
|
114
114
|
|
|
115
|
-
\- [LibPixiScrollContainerX-X
|
|
115
|
+
\- [LibPixiScrollContainerX-X轴滚动容器](#LibPixiScrollContainerX-X轴滚动容器)
|
|
116
116
|
|
|
117
|
-
\- [LibPixiScrollContainerY-Y
|
|
117
|
+
\- [LibPixiScrollContainerY-Y轴滚动容器](#LibPixiScrollContainerY-Y轴滚动容器)
|
|
118
118
|
|
|
119
119
|
\- [LibPixiScrollNum-数字滑动](#LibPixiScrollNum-数字滑动)
|
|
120
120
|
|
|
@@ -126,7 +126,7 @@ app.stage.addChild(box);
|
|
|
126
126
|
|
|
127
127
|
\- [LibPixiTable-数字表格](#LibPixiTable-数字表格)
|
|
128
128
|
|
|
129
|
-
\- [
|
|
129
|
+
\- [LibPixiLabelValue-标签值](#LibPixiLabelValue-标签值)
|
|
130
130
|
|
|
131
131
|
### 方法
|
|
132
132
|
|
|
@@ -662,7 +662,7 @@ progress.setProgress(0.5); //50% 完成
|
|
|
662
662
|
app.stage.addChild(progress);
|
|
663
663
|
```
|
|
664
664
|
|
|
665
|
-
### LibPixiScrollContainerX-X
|
|
665
|
+
### LibPixiScrollContainerX-X轴滚动容器
|
|
666
666
|
|
|
667
667
|
> 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
668
668
|
|
|
@@ -692,7 +692,7 @@ scrollContainer.setDimensions(800, 600);
|
|
|
692
692
|
scrollContainer.addContent(new Sprite(Texture.from("new-content.png")));
|
|
693
693
|
```
|
|
694
694
|
|
|
695
|
-
### LibPixiScrollContainerY-Y
|
|
695
|
+
### LibPixiScrollContainerY-Y轴滚动容器
|
|
696
696
|
|
|
697
697
|
> 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
|
|
698
698
|
|
|
@@ -881,6 +881,37 @@ const table = new LibPixiTable({
|
|
|
881
881
|
stage.addChild(table);
|
|
882
882
|
```
|
|
883
883
|
|
|
884
|
+
### LibPixiLabelValue-标签值
|
|
885
|
+
|
|
886
|
+
> 适用于左边图标右边动态数值锚点在容器正中间的场景
|
|
887
|
+
|
|
888
|
+
```ts
|
|
889
|
+
//单位
|
|
890
|
+
const unit = new LibPixiText({
|
|
891
|
+
text: "Rp",
|
|
892
|
+
fontSize: 40,
|
|
893
|
+
fontColor: "#fff551",
|
|
894
|
+
strokeThickness: 4,
|
|
895
|
+
stroke: "#cc5114",
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
//金额
|
|
899
|
+
const amount = new LibPixiText({
|
|
900
|
+
text: value,
|
|
901
|
+
fontSize: 40,
|
|
902
|
+
fontColor: "#fff551",
|
|
903
|
+
strokeThickness: 4,
|
|
904
|
+
stroke: "#cc5114",
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
//容器
|
|
908
|
+
const amountContainer = new LibLabelValue({
|
|
909
|
+
label: unit,
|
|
910
|
+
value: amount,
|
|
911
|
+
gap: 10,
|
|
912
|
+
});
|
|
913
|
+
```
|
|
914
|
+
|
|
884
915
|
## Utils-工具方法
|
|
885
916
|
|
|
886
917
|
### LibPixiAudio-音频播放器
|
package/libPixiJs.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ import { LibPixiRectangle } from "./Components/Base/LibPixiRectangle";
|
|
|
24
24
|
import { LibPixiPolygon } from "./Components/Base/LibPixiPolygon";
|
|
25
25
|
import { LibPixiCircular } from "./Components/Base/LibPixiCircular";
|
|
26
26
|
import { LibPixiSlide } from "./Components/Custom/LibPixiSlide";
|
|
27
|
+
import { LibPixiLabelValue } from "./Components/Custom/LibPixiLabelValue";
|
|
28
|
+
import { LibPixiPuzzleBg } from "./Components/Custom/LibPixiPuzzleBg";
|
|
27
29
|
/** @description 组件 */
|
|
28
30
|
export declare const Components: {
|
|
29
31
|
Base: {
|
|
@@ -117,6 +119,14 @@ export declare const Components: {
|
|
|
117
119
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
|
|
118
120
|
*/
|
|
119
121
|
LibPixiTable: typeof LibPixiTable;
|
|
122
|
+
/** @description 自适应宽度的标签和值组件
|
|
123
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
|
|
124
|
+
*/
|
|
125
|
+
LibPixiLabelValue: typeof LibPixiLabelValue;
|
|
126
|
+
/** @description 设计图背景拼接
|
|
127
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPuzzleBg-设计图背景拼接
|
|
128
|
+
*/
|
|
129
|
+
LibPixiPuzzleBg: typeof LibPixiPuzzleBg;
|
|
120
130
|
};
|
|
121
131
|
};
|
|
122
132
|
/** @description 方法 */
|
package/libPixiJs.js
CHANGED
|
@@ -39,6 +39,8 @@ import { LibPixiGridLayout } from "./Utils/LibPixiGridLayout";
|
|
|
39
39
|
import { LibPixiArrangeLinear } from "./Utils/LibPixiArrangeLinear";
|
|
40
40
|
import { LibPixiSlide } from "./Components/Custom/LibPixiSlide";
|
|
41
41
|
import { LibPixiEmitContainerEvent } from "./Utils/LibPixiEmitContainerEvent";
|
|
42
|
+
import { LibPixiLabelValue } from "./Components/Custom/LibPixiLabelValue";
|
|
43
|
+
import { LibPixiPuzzleBg } from "./Components/Custom/LibPixiPuzzleBg";
|
|
42
44
|
/** @description 组件 */
|
|
43
45
|
export const Components = {
|
|
44
46
|
Base: {
|
|
@@ -132,6 +134,14 @@ export const Components = {
|
|
|
132
134
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
|
|
133
135
|
*/
|
|
134
136
|
LibPixiTable,
|
|
137
|
+
/** @description 自适应宽度的标签和值组件
|
|
138
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
|
|
139
|
+
*/
|
|
140
|
+
LibPixiLabelValue,
|
|
141
|
+
/** @description 设计图背景拼接
|
|
142
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPuzzleBg-设计图背景拼接
|
|
143
|
+
*/
|
|
144
|
+
LibPixiPuzzleBg,
|
|
135
145
|
},
|
|
136
146
|
};
|
|
137
147
|
/** @description 方法 */
|