@safe-engine/pixi 8.4.7 → 8.5.4
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/README.md +17 -25
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +0 -23
- package/dist/box2d-wasm/ContactListener.d.ts +1 -1
- package/dist/box2d-wasm/ContactListener.d.ts.map +1 -1
- package/dist/box2d-wasm/ContactListener.js +50 -18
- package/dist/box2d-wasm/PhysicsComponent.d.ts +27 -30
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsComponent.js +44 -11
- package/dist/box2d-wasm/PhysicsSprite.d.ts +3 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSprite.js +24 -3
- package/dist/box2d-wasm/PhysicsSystem.d.ts +5 -3
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +135 -45
- package/dist/collider/CollideComponent.d.ts +27 -10
- package/dist/collider/CollideComponent.d.ts.map +1 -1
- package/dist/collider/CollideComponent.js +10 -12
- package/dist/collider/helper/Intersection.d.ts +6 -6
- package/dist/collider/helper/Intersection.d.ts.map +1 -1
- package/dist/collider/helper/Intersection.js +4 -4
- package/dist/collider/index.d.ts +1 -0
- package/dist/collider/index.d.ts.map +1 -1
- package/dist/collider/index.js +1 -0
- package/dist/components/NodeComp.d.ts +62 -36
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +18 -99
- package/dist/core/Color.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesComponent.d.ts +3 -2
- package/dist/dragonbones/DragonBonesComponent.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesComponent.js +1 -1
- package/dist/dragonbones/DragonBonesSystem.js +2 -2
- package/dist/gui/GUISystem.d.ts.map +1 -1
- package/dist/gui/GUISystem.js +5 -6
- package/dist/helper/utils.d.ts +0 -6
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +0 -12
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -5
- package/dist/norender/NoRenderComponent.d.ts +5 -1
- package/dist/norender/NoRenderComponent.d.ts.map +1 -1
- package/dist/norender/NoRenderSystem.d.ts.map +1 -1
- package/dist/norender/NoRenderSystem.js +8 -9
- package/dist/render/RenderComponent.d.ts +6 -17
- package/dist/render/RenderComponent.d.ts.map +1 -1
- package/dist/render/RenderComponent.js +26 -18
- package/dist/spine/lib/require-shim.d.ts.map +1 -1
- package/dist/spine/lib/require-shim.js +1 -1
- package/package.json +6 -7
- package/.github/workflows/npm-publish.yml +0 -35
- package/src/app.ts +0 -91
- package/src/base/EnhancedComponent.ts +0 -38
- package/src/base/gworld.ts +0 -20
- package/src/base/index.ts +0 -14
- package/src/base/utils.ts +0 -23
- package/src/box2d-wasm/ContactListener.ts +0 -66
- package/src/box2d-wasm/PhysicsComponent.ts +0 -83
- package/src/box2d-wasm/PhysicsSprite.ts +0 -42
- package/src/box2d-wasm/PhysicsSystem.ts +0 -142
- package/src/box2d-wasm/debugDraw.ts +0 -249
- package/src/box2d-wasm/index.ts +0 -19
- package/src/collider/CollideComponent.ts +0 -257
- package/src/collider/CollideSystem.ts +0 -166
- package/src/collider/helper/Intersection.ts +0 -139
- package/src/collider/helper/utils.ts +0 -37
- package/src/collider/index.ts +0 -16
- package/src/components/BaseComponent.ts +0 -17
- package/src/components/NodeComp.ts +0 -442
- package/src/components/Scene.ts +0 -17
- package/src/core/Color.ts +0 -7
- package/src/core/LoadingBar.ts +0 -63
- package/src/core/NodePool.ts +0 -28
- package/src/core/Size.ts +0 -21
- package/src/core/Vec2.ts +0 -108
- package/src/core/director.ts +0 -11
- package/src/core/index.ts +0 -7
- package/src/core/loader.ts +0 -14
- package/src/core/math.ts +0 -22
- package/src/dragonbones/DragonBonesComponent.ts +0 -32
- package/src/dragonbones/DragonBonesSystem.ts +0 -35
- package/src/dragonbones/index.ts +0 -11
- package/src/gui/GUIComponent.ts +0 -155
- package/src/gui/GUISystem.ts +0 -125
- package/src/helper/utils.ts +0 -50
- package/src/index.ts +0 -21
- package/src/norender/NoRenderComponent.ts +0 -60
- package/src/norender/NoRenderSystem.ts +0 -67
- package/src/norender/Touch.ts +0 -37
- package/src/planck/PhysicsComponent.ts +0 -83
- package/src/planck/PhysicsSprite.ts +0 -43
- package/src/planck/PhysicsSystem.ts +0 -201
- package/src/planck/index.ts +0 -3
- package/src/render/RenderComponent.ts +0 -132
- package/src/render/RenderSystem.ts +0 -64
- package/src/richtext/RichTextComp.ts +0 -50
- package/src/richtext/RichTextSystem.ts +0 -26
- package/src/richtext/html-text-parser.ts +0 -87
- package/src/richtext/index.ts +0 -8
- package/src/spine/SpineComponent.ts +0 -18
- package/src/spine/SpineSystem.ts +0 -30
- package/src/spine/index.ts +0 -11
- package/src/spine/lib/BatchableSpineSlot.ts +0 -138
- package/src/spine/lib/Spine.ts +0 -894
- package/src/spine/lib/SpineDebugRenderer.ts +0 -615
- package/src/spine/lib/SpinePipe.ts +0 -203
- package/src/spine/lib/SpineTexture.ts +0 -143
- package/src/spine/lib/assets/atlasLoader.ts +0 -158
- package/src/spine/lib/assets/skeletonLoader.ts +0 -81
- package/src/spine/lib/darktint/DarkTintBatchGeometry.ts +0 -92
- package/src/spine/lib/darktint/DarkTintBatcher.ts +0 -186
- package/src/spine/lib/darktint/DarkTintShader.ts +0 -74
- package/src/spine/lib/darktint/darkTintBit.ts +0 -77
- package/src/spine/lib/index.ts +0 -43
- package/src/spine/lib/require-shim.ts +0 -43
- package/tsconfig.json +0 -18
- /package/{src/@types → @types}/index.d.ts +0 -0
package/src/core/LoadingBar.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Container, Graphics, Point, Sprite, Texture } from 'pixi.js'
|
|
2
|
-
|
|
3
|
-
export enum LoadingBarMode {
|
|
4
|
-
BAR,
|
|
5
|
-
RADIAL,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class LoadingBar extends Graphics {
|
|
9
|
-
spriteComp: Sprite
|
|
10
|
-
mode: LoadingBarMode
|
|
11
|
-
fillCenter = new Point(0.5, 0.5)
|
|
12
|
-
constructor(mode: LoadingBarMode, spriteComp: Sprite) {
|
|
13
|
-
super()
|
|
14
|
-
this.spriteComp = spriteComp
|
|
15
|
-
this.mode = mode || LoadingBarMode.BAR
|
|
16
|
-
this.fill(0xffffff)
|
|
17
|
-
this.rect(0, 0, spriteComp.width, spriteComp.height)
|
|
18
|
-
spriteComp.mask = this
|
|
19
|
-
spriteComp.addChild(this)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
set progress(val: number) {
|
|
23
|
-
this.clear()
|
|
24
|
-
this.fill(0xffffff)
|
|
25
|
-
if (this.mode === LoadingBarMode.BAR) {
|
|
26
|
-
const spriteComp = this.spriteComp
|
|
27
|
-
this.rect(0, 0, spriteComp.width * val, spriteComp.height)
|
|
28
|
-
// console.log('new length', spriteComp.width)
|
|
29
|
-
this.x = -spriteComp.width * 0.5
|
|
30
|
-
this.y = -spriteComp.height * 0.5
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class ProgressTimer extends Container {
|
|
36
|
-
graphics: Graphics
|
|
37
|
-
spriteComp: Sprite
|
|
38
|
-
mode: LoadingBarMode
|
|
39
|
-
fillCenter = new Point(0.5, 0.5)
|
|
40
|
-
constructor(mode: LoadingBarMode, spriteFrame: string) {
|
|
41
|
-
super()
|
|
42
|
-
const texture = Texture.from(spriteFrame)
|
|
43
|
-
this.spriteComp = Sprite.from(texture)
|
|
44
|
-
this.graphics = new Graphics()
|
|
45
|
-
this.mode = mode || LoadingBarMode.BAR
|
|
46
|
-
this.graphics.fill(0xffffff)
|
|
47
|
-
this.graphics.rect(0, 0, this.spriteComp.width, this.spriteComp.height)
|
|
48
|
-
this.spriteComp.mask = this.graphics
|
|
49
|
-
this.addChild(this.graphics)
|
|
50
|
-
this.addChild(this.spriteComp)
|
|
51
|
-
// this.graphics.x = -this.spriteComp.width * this.fillCenter.x
|
|
52
|
-
// this.graphics.y = -this.spriteComp.height * this.fillCenter.y
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
set progress(val: number) {
|
|
56
|
-
this.graphics.clear()
|
|
57
|
-
if (this.mode === LoadingBarMode.BAR) {
|
|
58
|
-
this.graphics.rect(0, 0, this.spriteComp.width * val, this.spriteComp.height)
|
|
59
|
-
// console.log('new length', this.width)
|
|
60
|
-
this.graphics.fill(0xffffff)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/core/NodePool.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { NodeComp } from "../components/NodeComp"
|
|
2
|
-
|
|
3
|
-
export class NodePool {
|
|
4
|
-
items: NodeComp[] = []
|
|
5
|
-
|
|
6
|
-
put(node: NodeComp) {
|
|
7
|
-
if (node) {
|
|
8
|
-
node.active = false
|
|
9
|
-
node.removeFromParent()
|
|
10
|
-
this.items.push(node)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
get(): NodeComp {
|
|
15
|
-
const node = this.items.pop()
|
|
16
|
-
node.active = true
|
|
17
|
-
return node
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
size() {
|
|
21
|
-
return this.items.length
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
clear() {
|
|
25
|
-
this.items.forEach((node) => node.destroy())
|
|
26
|
-
this.items.length = 0
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/core/Size.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
class _Size {
|
|
2
|
-
width: number
|
|
3
|
-
height: number
|
|
4
|
-
static ZERO
|
|
5
|
-
constructor(width = 0, height = 0) {
|
|
6
|
-
if (!(this instanceof _Size)) {
|
|
7
|
-
return new _Size(width, height)
|
|
8
|
-
}
|
|
9
|
-
if (height === undefined) {
|
|
10
|
-
this.width = (width as any).width
|
|
11
|
-
this.height = (width as any).height
|
|
12
|
-
}
|
|
13
|
-
this.width = width
|
|
14
|
-
this.height = height
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type Size = _Size
|
|
19
|
-
export function Size(x?: number, y?: number): Size {
|
|
20
|
-
return new _Size(x, y)
|
|
21
|
-
}
|
package/src/core/Vec2.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Point } from 'pixi.js'
|
|
2
|
-
|
|
3
|
-
import { clampf } from './math'
|
|
4
|
-
|
|
5
|
-
export function updatePoint(p) {
|
|
6
|
-
const { x, y } = p
|
|
7
|
-
return Vec2(x, y)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
class _Vec2 {
|
|
11
|
-
x: number
|
|
12
|
-
y: number
|
|
13
|
-
static ZERO
|
|
14
|
-
constructor(x: number | object = 0, y = 0) {
|
|
15
|
-
if (!(this instanceof _Vec2)) {
|
|
16
|
-
return new _Vec2(x, y)
|
|
17
|
-
}
|
|
18
|
-
if (typeof x === 'object') {
|
|
19
|
-
this.x = (x as any).x
|
|
20
|
-
this.y = (x as any).y
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
this.x = x
|
|
24
|
-
this.y = y
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
equals(other: _Vec2) {
|
|
28
|
-
return this.x === other.x && this.y === other.y
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
add(value: Point | Vec2): _Vec2 {
|
|
32
|
-
return updatePoint(new Point(this.x, this.y).add(value))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
addSelf(value: Point | Vec2): _Vec2 {
|
|
36
|
-
const nor = updatePoint(new Point(this.x, this.y).add(value))
|
|
37
|
-
this.x = nor.x
|
|
38
|
-
this.y = nor.y
|
|
39
|
-
return nor
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
sub(value: Point | Vec2): _Vec2 {
|
|
43
|
-
return updatePoint(new Point(this.x, this.y).subtract(value))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
mul(multiply: number): _Vec2 {
|
|
47
|
-
return updatePoint(new Point(this.x, this.y).multiply(new Point(multiply, multiply)))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
mulSelf(multiply: number): _Vec2 {
|
|
51
|
-
const nor = updatePoint(new Point(this.x, this.y).multiply(new Point(multiply, multiply)))
|
|
52
|
-
this.x = nor.x
|
|
53
|
-
this.y = nor.y
|
|
54
|
-
return nor
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
mag(): number {
|
|
58
|
-
return new Point(this.x, this.y).magnitude()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
normalizeSelf(): _Vec2 {
|
|
62
|
-
const nor = updatePoint(new Point(this.x, this.y).normalize())
|
|
63
|
-
this.x = nor.x
|
|
64
|
-
this.y = nor.y
|
|
65
|
-
return nor
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
normalize(): _Vec2 {
|
|
69
|
-
return updatePoint(new Point(this.x, this.y).normalize())
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public cross(other: Vec2) {
|
|
73
|
-
return this.x * other.y - this.y * other.x
|
|
74
|
-
}
|
|
75
|
-
public signAngle(other: Vec2) {
|
|
76
|
-
const angle = this.angle(other)
|
|
77
|
-
return this.cross(other) < 0 ? -angle : angle
|
|
78
|
-
}
|
|
79
|
-
public lengthSqr() {
|
|
80
|
-
return this.x * this.x + this.y * this.y
|
|
81
|
-
}
|
|
82
|
-
public dot(other: Vec2) {
|
|
83
|
-
return this.x * other.x + this.y * other.y
|
|
84
|
-
}
|
|
85
|
-
public angle(other: Vec2) {
|
|
86
|
-
const magSqr1 = this.lengthSqr()
|
|
87
|
-
const magSqr2 = other.lengthSqr()
|
|
88
|
-
|
|
89
|
-
if (magSqr1 === 0 || magSqr2 === 0) {
|
|
90
|
-
console.warn('Cant get angle between zero vector')
|
|
91
|
-
return 0.0
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const dot = this.dot(other)
|
|
95
|
-
let theta = dot / Math.sqrt(magSqr1 * magSqr2)
|
|
96
|
-
theta = clampf(theta, -1.0, 1.0)
|
|
97
|
-
return Math.acos(theta)
|
|
98
|
-
}
|
|
99
|
-
public distance(other: _Vec2) {
|
|
100
|
-
return this.sub(other).mag()
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
export type Vec2 = _Vec2
|
|
104
|
-
export function Vec2(x?: number | object, y?: number): Vec2 {
|
|
105
|
-
return new _Vec2(x, y)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
Vec2.ZERO = Object.freeze(Vec2(0, 0))
|
package/src/core/director.ts
DELETED
package/src/core/index.ts
DELETED
package/src/core/loader.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AssetsClass } from 'pixi.js'
|
|
2
|
-
|
|
3
|
-
const jsonCache = {}
|
|
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
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function loadJsonFromCache<T>(filePath: string): T {
|
|
13
|
-
return jsonCache[filePath]
|
|
14
|
-
}
|
package/src/core/math.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DEG_TO_RAD, RAD_TO_DEG } from 'pixi.js'
|
|
2
|
-
|
|
3
|
-
export function randomRangeInt(minInclude: Integer, maxExclude: Integer) {
|
|
4
|
-
return Math.round(Math.random() * (maxExclude - minInclude - 1)) + minInclude
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function degreesToRadians(deg: Float) {
|
|
8
|
-
return DEG_TO_RAD * deg
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function radiansToDegrees(rad: Float) {
|
|
12
|
-
return RAD_TO_DEG * rad
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function clampf(theta: number, arg1: number, arg2: number): number {
|
|
16
|
-
if (theta < arg1) {
|
|
17
|
-
return arg1
|
|
18
|
-
} else if (theta > arg2) {
|
|
19
|
-
return arg2
|
|
20
|
-
}
|
|
21
|
-
return theta
|
|
22
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ComponentX } from "../components/BaseComponent"
|
|
2
|
-
interface DragonBonesData {
|
|
3
|
-
atlas: string
|
|
4
|
-
skeleton: string
|
|
5
|
-
texture: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface DragonBonesProps {
|
|
9
|
-
data: DragonBonesData
|
|
10
|
-
skin?: string
|
|
11
|
-
animation?: string
|
|
12
|
-
playTimes?: number
|
|
13
|
-
timeScale?: number
|
|
14
|
-
onAnimationStart?: (event: { name: string }) => void
|
|
15
|
-
onAnimationEnd?: (event: { name: string }) => void
|
|
16
|
-
onAnimationComplete?: (event: { name: string }) => void
|
|
17
|
-
}
|
|
18
|
-
export class DragonBones extends ComponentX<DragonBonesProps> {
|
|
19
|
-
|
|
20
|
-
setAnimation(name: string, playTimes = 0) {
|
|
21
|
-
const skel: any = this.node.instance
|
|
22
|
-
if (skel.animation) {
|
|
23
|
-
skel.animation.play(name, playTimes)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
setSkeletonData(data: string) {
|
|
28
|
-
const skel: any = this.node.instance
|
|
29
|
-
const atlas = data.replace('.json', '.atlas')
|
|
30
|
-
skel.initWithArgs(data, atlas, this.node.scale)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { PixiFactory } from 'dragonbones-pixijs';
|
|
2
|
-
import { EntityManager, EventManager, EventTypes, System } from 'entityx-ts';
|
|
3
|
-
|
|
4
|
-
import { Assets } from 'pixi.js';
|
|
5
|
-
import { GameWorld } from '../base';
|
|
6
|
-
import { NodeComp } from '../components/NodeComp';
|
|
7
|
-
import { DragonBones } from './DragonBonesComponent';
|
|
8
|
-
|
|
9
|
-
export class DragonBonesSystem implements System {
|
|
10
|
-
configure(event_manager: EventManager<GameWorld>) {
|
|
11
|
-
event_manager.subscribe(EventTypes.ComponentAdded, DragonBones, ({ entity, component }) => {
|
|
12
|
-
const { data, animation, playTimes = 0 } = component.props
|
|
13
|
-
const { skeleton, atlas, texture } = data
|
|
14
|
-
const skeletonAsset = Assets.get(skeleton)
|
|
15
|
-
const atlasAsset = Assets.get(atlas)
|
|
16
|
-
const textureAsset = Assets.get(texture)
|
|
17
|
-
const armatureName = skeletonAsset.armature[0].name
|
|
18
|
-
// console.log(skeletonAsset, textureAsset, atlasAsset)
|
|
19
|
-
const factory = PixiFactory.factory;
|
|
20
|
-
factory.parseDragonBonesData(skeletonAsset);
|
|
21
|
-
factory.parseTextureAtlasData(atlasAsset, textureAsset)
|
|
22
|
-
const armatureDisplay = factory.buildArmatureDisplay(armatureName)!;
|
|
23
|
-
armatureDisplay.debugDraw = false;
|
|
24
|
-
const node = armatureDisplay;
|
|
25
|
-
if (animation) {
|
|
26
|
-
armatureDisplay.animation.play(animation, playTimes);
|
|
27
|
-
}
|
|
28
|
-
component.node = entity.assign(new NodeComp(node, entity))
|
|
29
|
-
})
|
|
30
|
-
// event_manager.subscribe(EventTypes.ComponentRemoved, DragonBones, ({ }) => { })
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
update(entities: EntityManager, events: EventManager<GameWorld>, dt: number) {
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/dragonbones/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GameWorld } from '..'
|
|
2
|
-
import { DragonBonesSystem } from './DragonBonesSystem'
|
|
3
|
-
|
|
4
|
-
export * from './DragonBonesComponent'
|
|
5
|
-
export * from './DragonBonesSystem'
|
|
6
|
-
|
|
7
|
-
export function setupDragonBones() {
|
|
8
|
-
GameWorld.Instance.systems.add(DragonBonesSystem)
|
|
9
|
-
GameWorld.Instance.listUpdate.push(DragonBonesSystem)
|
|
10
|
-
GameWorld.Instance.systems.configureOnce(DragonBonesSystem)
|
|
11
|
-
}
|
package/src/gui/GUIComponent.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { CheckBox, CheckBoxOptions, Input, List, ProgressBar, RadioGroup, Slider, SliderOptions } from '@pixi/ui'
|
|
2
|
-
import { Assets, Container, Point, Text } from 'pixi.js'
|
|
3
|
-
|
|
4
|
-
import { BaseComponentProps } from '..'
|
|
5
|
-
import { ComponentX, NoRenderComponentX } from '../components/BaseComponent'
|
|
6
|
-
import { Color4B } from '../core/Color'
|
|
7
|
-
import { LoadingBarMode, ProgressTimer } from '../core/LoadingBar'
|
|
8
|
-
|
|
9
|
-
export const FillType = {
|
|
10
|
-
HORIZONTAL: 0,
|
|
11
|
-
VERTICAL: 1,
|
|
12
|
-
RADIAL: 2,
|
|
13
|
-
}
|
|
14
|
-
// type Keys = keyof typeof FillType
|
|
15
|
-
// type Values = (typeof FillType)[Keys]
|
|
16
|
-
|
|
17
|
-
interface ButtonCompProps extends BaseComponentProps<ButtonComp> {
|
|
18
|
-
normalImage?: string
|
|
19
|
-
selectedImage?: string
|
|
20
|
-
disableImage?: string
|
|
21
|
-
zoomScale?: number
|
|
22
|
-
onPress: (target: ButtonComp) => void
|
|
23
|
-
}
|
|
24
|
-
export class ButtonComp extends NoRenderComponentX<ButtonCompProps> {
|
|
25
|
-
// setOnPress(cb: (target: ButtonComp) => void) {
|
|
26
|
-
// this.onPress = cb
|
|
27
|
-
// }
|
|
28
|
-
// set enabled(val) {
|
|
29
|
-
// this.node.instance.interactive = val
|
|
30
|
-
// }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class ProgressBarComp extends ComponentX<{}, ProgressBar> {
|
|
34
|
-
mode = LoadingBarMode.BAR
|
|
35
|
-
isReverse: boolean
|
|
36
|
-
bg: string
|
|
37
|
-
fill: string
|
|
38
|
-
|
|
39
|
-
get progress() {
|
|
40
|
-
return this.node.instance.progress
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
set progress(val: number) {
|
|
44
|
-
this.node.instance.progress = val
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
interface LabelCompProps extends BaseComponentProps<LabelComp> {
|
|
48
|
-
font?: string
|
|
49
|
-
string?: string
|
|
50
|
-
size?: number
|
|
51
|
-
}
|
|
52
|
-
export class LabelComp extends ComponentX<LabelCompProps, Text> {
|
|
53
|
-
get string() {
|
|
54
|
-
return this.props.string
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
set string(val: string) {
|
|
58
|
-
this.props.string = val
|
|
59
|
-
if (!this.node) return
|
|
60
|
-
if (this.node.instance instanceof Text) {
|
|
61
|
-
this.node.instance.text = val
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get size() {
|
|
66
|
-
return this.props.size
|
|
67
|
-
}
|
|
68
|
-
set size(val) {
|
|
69
|
-
this.props.size = val
|
|
70
|
-
if (!this.node) return
|
|
71
|
-
if (this.node.instance instanceof Text) {
|
|
72
|
-
this.node.instance.style.fontSize = val
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get font() {
|
|
77
|
-
return this.props.font
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
set font(val: string) {
|
|
81
|
-
this.props.font = val
|
|
82
|
-
if (!this.node) return
|
|
83
|
-
// console.log('set font', val, Assets.get(val))
|
|
84
|
-
if (this.node.instance instanceof Text) {
|
|
85
|
-
if (Assets.get(val)) this.node.instance.style.fontFamily = Assets.get(val).family
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
interface ScrollViewProps {
|
|
91
|
-
width: number
|
|
92
|
-
height: number
|
|
93
|
-
}
|
|
94
|
-
export class ScrollView extends NoRenderComponentX<ScrollViewProps> {}
|
|
95
|
-
|
|
96
|
-
export class BlockInputEventsComp extends NoRenderComponentX {}
|
|
97
|
-
|
|
98
|
-
interface ProgressTimerProps extends BaseComponentProps<ProgressTimerComp> {
|
|
99
|
-
spriteFrame: string
|
|
100
|
-
fillType?: number
|
|
101
|
-
fillRange?: number
|
|
102
|
-
fillCenter?: Point
|
|
103
|
-
isReverse?: boolean
|
|
104
|
-
}
|
|
105
|
-
export class ProgressTimerComp extends ComponentX<ProgressTimerProps, ProgressTimer> {
|
|
106
|
-
getFillRange() {
|
|
107
|
-
return this.node.instance.progress
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
setFillStart(val: number) {
|
|
111
|
-
this.node.instance.fillCenter.x = val
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
setFillRange(val: number) {
|
|
115
|
-
// console.log('setFillRange', this.node.instance);
|
|
116
|
-
this.node.instance.progress = val
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
interface LabelOutlineCompProps {
|
|
121
|
-
color: Color4B
|
|
122
|
-
width: number
|
|
123
|
-
}
|
|
124
|
-
export class LabelOutlineComp extends NoRenderComponentX<LabelOutlineCompProps> {}
|
|
125
|
-
|
|
126
|
-
interface LabelShadowCompProps extends BaseComponentProps<LabelShadowComp> {
|
|
127
|
-
color: Color4B
|
|
128
|
-
blur: number
|
|
129
|
-
offset?: Point
|
|
130
|
-
}
|
|
131
|
-
export class LabelShadowComp extends NoRenderComponentX<LabelShadowCompProps> {}
|
|
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
|
|
141
|
-
}
|
|
142
|
-
export class InputComp extends ComponentX<InputCompProps, Input> {
|
|
143
|
-
get string() {
|
|
144
|
-
return this.node.instance.value
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export class ListComp extends ComponentX<{}, List> {}
|
|
149
|
-
export class SliderComp extends ComponentX<{}, Slider> {
|
|
150
|
-
bg: string
|
|
151
|
-
fill: SliderOptions['fill']
|
|
152
|
-
slider: Container
|
|
153
|
-
}
|
|
154
|
-
export class RadioGroupComp extends ComponentX<{}, RadioGroup> {}
|
|
155
|
-
export class CheckBoxComp extends ComponentX<{ style: CheckBoxOptions['style'] }, CheckBox> {}
|
package/src/gui/GUISystem.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Button, CheckBox, Input, List, RadioGroup, ScrollBox } from '@pixi/ui'
|
|
2
|
-
import { EventManager, EventTypes, System } from 'entityx-ts'
|
|
3
|
-
import { callFunc, easeBackIn, scaleTo, sequence } from 'pixi-action-ease'
|
|
4
|
-
import { Text } from 'pixi.js'
|
|
5
|
-
|
|
6
|
-
import { Color4B, NodeComp } from '..'
|
|
7
|
-
import { GameWorld } from '../base'
|
|
8
|
-
import { LoadingBarMode, ProgressTimer } from '../core/LoadingBar'
|
|
9
|
-
import {
|
|
10
|
-
ButtonComp,
|
|
11
|
-
CheckBoxComp,
|
|
12
|
-
InputComp,
|
|
13
|
-
LabelComp,
|
|
14
|
-
LabelOutlineComp,
|
|
15
|
-
LabelShadowComp,
|
|
16
|
-
ListComp,
|
|
17
|
-
ProgressTimerComp,
|
|
18
|
-
RadioGroupComp,
|
|
19
|
-
ScrollView,
|
|
20
|
-
} from './GUIComponent'
|
|
21
|
-
|
|
22
|
-
export class GUISystem implements System {
|
|
23
|
-
defaultFont: string
|
|
24
|
-
configure(event_manager: EventManager<GameWorld>) {
|
|
25
|
-
event_manager.subscribe(EventTypes.ComponentAdded, ButtonComp, ({ entity, component }) => {
|
|
26
|
-
const nodeComp = entity.getComponent(NodeComp)
|
|
27
|
-
// const { normalImage, selectedImage, disableImage, texType, zoomScale } = button
|
|
28
|
-
// console.log('onPress.ButtonComp', component)
|
|
29
|
-
const button = new Button(nodeComp.instance)
|
|
30
|
-
// node.setZoomScale(zoomScale - 1)
|
|
31
|
-
component.node = nodeComp
|
|
32
|
-
// component.node = entity.assign(new NodeComp(node, entity))
|
|
33
|
-
button.onPress.connect(() => {
|
|
34
|
-
if (!component.enabled) return
|
|
35
|
-
// console.log('onPress.connect')
|
|
36
|
-
const scale = scaleTo(0.5, 1.2)
|
|
37
|
-
const scaleDown = scaleTo(0.5, 1)
|
|
38
|
-
const seq = sequence(
|
|
39
|
-
scale,
|
|
40
|
-
callFunc(() => {
|
|
41
|
-
if (Object.prototype.hasOwnProperty.call(component.props, 'onPress')) {
|
|
42
|
-
component.props.onPress(component)
|
|
43
|
-
}
|
|
44
|
-
}),
|
|
45
|
-
scaleDown,
|
|
46
|
-
)
|
|
47
|
-
const ease = easeBackIn(seq)
|
|
48
|
-
component.node.runAction(ease)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
// event_manager.subscribe(EventTypes.ComponentAdded, ProgressBarComp, ({ entity, component }) => {
|
|
52
|
-
// const { progress = 1, bg, fill } = component.props
|
|
53
|
-
// const node = new ProgressBar({ bg, fill, progress })
|
|
54
|
-
// component.node = entity.assign(new NodeComp(node, entity))
|
|
55
|
-
// })
|
|
56
|
-
event_manager.subscribe(EventTypes.ComponentAdded, ProgressTimerComp, ({ entity, component }) => {
|
|
57
|
-
// console.log(component, '.progress')
|
|
58
|
-
const { spriteFrame, fillCenter, fillRange = 0 } = component.props
|
|
59
|
-
const node = new ProgressTimer(LoadingBarMode.BAR, spriteFrame)
|
|
60
|
-
if (fillCenter) {
|
|
61
|
-
node.fillCenter = fillCenter
|
|
62
|
-
}
|
|
63
|
-
node.progress = fillRange * 100
|
|
64
|
-
component.node = entity.assign(new NodeComp(node, entity))
|
|
65
|
-
})
|
|
66
|
-
event_manager.subscribe(EventTypes.ComponentAdded, ScrollView, ({ entity, component }) => {
|
|
67
|
-
const { width, height } = component.props
|
|
68
|
-
const view = new ScrollBox({ width, height })
|
|
69
|
-
component.node = entity.assign(new NodeComp(view, entity))
|
|
70
|
-
})
|
|
71
|
-
event_manager.subscribe(EventTypes.ComponentAdded, ListComp, ({ entity, component }) => {
|
|
72
|
-
const view = new List()
|
|
73
|
-
component.node = entity.assign(new NodeComp(view, entity))
|
|
74
|
-
})
|
|
75
|
-
// event_manager.subscribe(EventTypes.ComponentAdded, SliderComp, ({ entity, component }) => {
|
|
76
|
-
// const { bg, slider, fill } = component.props
|
|
77
|
-
// const view = new Slider({ bg, fill, slider })
|
|
78
|
-
// component.node = entity.assign(new NodeComp(view, entity))
|
|
79
|
-
// })
|
|
80
|
-
event_manager.subscribe(EventTypes.ComponentAdded, RadioGroupComp, ({ entity, component }) => {
|
|
81
|
-
const view = new RadioGroup()
|
|
82
|
-
component.node = entity.assign(new NodeComp(view, entity))
|
|
83
|
-
})
|
|
84
|
-
event_manager.subscribe(EventTypes.ComponentAdded, CheckBoxComp, ({ entity, component }) => {
|
|
85
|
-
const { style } = component.props
|
|
86
|
-
const view = new CheckBox({ style })
|
|
87
|
-
component.node = entity.assign(new NodeComp(view, entity))
|
|
88
|
-
})
|
|
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
|
-
})
|
|
94
|
-
event_manager.subscribe(EventTypes.ComponentAdded, LabelComp, ({ entity, component }) => {
|
|
95
|
-
// console.log('ComponentAddedEvent LabelComp', component)
|
|
96
|
-
const node = new Text()
|
|
97
|
-
// node.texture.rotate = 8
|
|
98
|
-
node.style.fill = '#fff'
|
|
99
|
-
component.node = entity.assign(new NodeComp(node, entity))
|
|
100
|
-
const { string = '', font = this.defaultFont, size = 64 } = component.props
|
|
101
|
-
if (font) component.font = font
|
|
102
|
-
component.size = size
|
|
103
|
-
component.string = string
|
|
104
|
-
})
|
|
105
|
-
event_manager.subscribe(EventTypes.ComponentAdded, LabelOutlineComp, ({ entity, component }) => {
|
|
106
|
-
const { color, width } = component.props
|
|
107
|
-
const node = entity.getComponent(NodeComp)
|
|
108
|
-
if (node.instance instanceof Text) {
|
|
109
|
-
node.instance.style.stroke = { color, width }
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
event_manager.subscribe(EventTypes.ComponentAdded, LabelShadowComp, ({ entity, component }) => {
|
|
113
|
-
const { color, blur } = component.props
|
|
114
|
-
const node = entity.getComponent(NodeComp)
|
|
115
|
-
if (node.instance instanceof Text) {
|
|
116
|
-
node.instance.style.dropShadow = { color, blur, alpha: 1, angle: 0, distance: 0 }
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
// event_manager.subscribe(EventTypes.ComponentAdded, BlockInputEventsComp), this);
|
|
121
|
-
}
|
|
122
|
-
// update() {
|
|
123
|
-
// throw new Error('Method not implemented.');
|
|
124
|
-
// }
|
|
125
|
-
}
|
package/src/helper/utils.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Constructor, EntityManager, EventManager, EventReceive, EventTypes, System } from 'entityx-ts';
|
|
2
|
-
import { Point } from 'pixi.js';
|
|
3
|
-
import { EnhancedComponent, GameWorld } from '../base';
|
|
4
|
-
|
|
5
|
-
import { NodeComp } from '../components/NodeComp';
|
|
6
|
-
|
|
7
|
-
export function v2(x: number | { x: number, y: number } = 0, y = 0) {
|
|
8
|
-
if (typeof x === 'object' && 'x' in x && 'y' in x) {
|
|
9
|
-
return new Point(x.x, x.y)
|
|
10
|
-
}
|
|
11
|
-
return new Point(x, y)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getDistance(point1: Point, point2: Point) {
|
|
15
|
-
const dx = point2.x - point1.x;
|
|
16
|
-
const dy = point2.y - point1.y;
|
|
17
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function registerSystem<T extends EnhancedComponent<any>>(component: Constructor<T>) {
|
|
21
|
-
if (GameWorld.Instance.systems.isRegistered(`${component.name}System`)) {
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
class NewSystem implements System {
|
|
25
|
-
configure(event_manager: EventManager<GameWorld>) {
|
|
26
|
-
console.log('configure registerSystem core', component.name)
|
|
27
|
-
event_manager.subscribe(EventTypes.ComponentAdded, component, (event: EventReceive<T>) => {
|
|
28
|
-
// console.log('receiveComponentAddedEvent', event)
|
|
29
|
-
const ett = event.entity
|
|
30
|
-
const newComp = ett.getComponent<T>(component)
|
|
31
|
-
newComp.node = ett.getComponent(NodeComp)
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
update(entities: EntityManager, events: EventManager<GameWorld>, dt: number) {
|
|
36
|
-
for (const entt of entities.entities_with_components(component)) {
|
|
37
|
-
const comp = entt.getComponent(component)
|
|
38
|
-
// console.log('comp', comp.constructor.name, typeof comp['update'] === 'function')
|
|
39
|
-
if (comp.node.active && typeof comp['update'] === 'function') {
|
|
40
|
-
comp['update'](dt)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
Object.defineProperty(NewSystem, 'name', { value: `${component.name}System` })
|
|
46
|
-
GameWorld.Instance.systems.add(NewSystem)
|
|
47
|
-
GameWorld.Instance.systems.configureOnce(NewSystem)
|
|
48
|
-
GameWorld.Instance.listUpdate.push(NewSystem)
|
|
49
|
-
return NewSystem
|
|
50
|
-
}
|