@safe-engine/pixi 8.4.6 → 8.5.1
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 +14 -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 +4 -2
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +134 -44
- 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/components/NodeComp.js +1 -1
- 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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/{src/spine/lib/require-shim.ts → dist/spine/lib/assets/atlasLoader.d.ts} +5 -14
- package/dist/spine/lib/assets/atlasLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/atlasLoader.js +122 -0
- package/{src/spine/lib/darktint/DarkTintShader.ts → dist/spine/lib/assets/skeletonLoader.d.ts} +3 -47
- package/dist/spine/lib/assets/skeletonLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/skeletonLoader.js +70 -0
- package/package.json +6 -2
- package/.github/workflows/npm-publish.yml +0 -35
- package/dist/@types/safex.d.ts +0 -15
- package/src/@types/index.d.ts +0 -2
- 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 -19
- 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/darktint/DarkTintBatchGeometry.ts +0 -92
- package/src/spine/lib/darktint/DarkTintBatcher.ts +0 -186
- package/src/spine/lib/darktint/darkTintBit.ts +0 -77
- package/src/spine/lib/index.ts +0 -43
- package/tsconfig.json +0 -18
- /package/{dist/@types → @types}/index.d.ts +0 -0
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
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export * from 'pixi.js'
|
|
2
|
-
export * from './app'
|
|
3
|
-
export * from './base'
|
|
4
|
-
export * from './collider'
|
|
5
|
-
export * from './collider/helper/Intersection'
|
|
6
|
-
export * from './components/BaseComponent'
|
|
7
|
-
export * from './components/NodeComp'
|
|
8
|
-
export * from './components/Scene'
|
|
9
|
-
export * from './core'
|
|
10
|
-
export * from './dragonbones'
|
|
11
|
-
export * from './gui/GUIComponent'
|
|
12
|
-
export * from './gui/GUISystem'
|
|
13
|
-
export * from './helper/utils'
|
|
14
|
-
export * from './norender/NoRenderComponent'
|
|
15
|
-
export * from './norender/Touch'
|
|
16
|
-
export * from './render/RenderComponent'
|
|
17
|
-
export * from './render/RenderSystem'
|
|
18
|
-
export * from './richtext'
|
|
19
|
-
export * from './spine'
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { NoRenderComponentX } from '../components/BaseComponent'
|
|
2
|
-
import { EventCallbackType, EventMap, NodeComp } from '../components/NodeComp'
|
|
3
|
-
import { Touch } from './Touch'
|
|
4
|
-
|
|
5
|
-
// export class Touch extends FederatedPointerEvent {
|
|
6
|
-
// declare getLocation: () => Vec2
|
|
7
|
-
// declare getDelta: () => Vec2
|
|
8
|
-
// }
|
|
9
|
-
|
|
10
|
-
export type TouchEventCallback = (touch?: Touch, node?: NodeComp) => void
|
|
11
|
-
|
|
12
|
-
export class EventRegister extends NoRenderComponentX {
|
|
13
|
-
events: EventMap = {}
|
|
14
|
-
|
|
15
|
-
on(name: string, callback: EventCallbackType, target?: any) {
|
|
16
|
-
const bound = target ? callback.bind(target) : callback
|
|
17
|
-
if (this.events[name]) {
|
|
18
|
-
this.events[name].push(bound)
|
|
19
|
-
} else {
|
|
20
|
-
this.events[name] = [bound]
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
off(name: string, callback?: EventCallbackType, target?: any)
|
|
25
|
-
off(name: string) {
|
|
26
|
-
this.events[name] = undefined
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
emit(name: string, ...params: any) {
|
|
30
|
-
if (this.events[name]) {
|
|
31
|
-
this.events[name].forEach((fc) => fc(...params))
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface TouchEventProps {
|
|
37
|
-
onTouchStart?: TouchEventCallback
|
|
38
|
-
onTouchMove?: TouchEventCallback
|
|
39
|
-
onTouchEnd?: TouchEventCallback
|
|
40
|
-
onTouchCancel?: TouchEventCallback
|
|
41
|
-
}
|
|
42
|
-
export class TouchEventRegister extends NoRenderComponentX<TouchEventProps> {
|
|
43
|
-
listener: EventListener
|
|
44
|
-
touch: Touch
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface ExtraDataProps {
|
|
48
|
-
key: string
|
|
49
|
-
value: any
|
|
50
|
-
}
|
|
51
|
-
export class ExtraDataComp extends NoRenderComponentX<ExtraDataProps> {
|
|
52
|
-
data: { [key: string]: any } = {}
|
|
53
|
-
|
|
54
|
-
getData<T>(key: string): T {
|
|
55
|
-
return this.data[key]
|
|
56
|
-
}
|
|
57
|
-
setData<T>(key: string, val: T) {
|
|
58
|
-
this.data[key] = val
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { EventManager, EventTypes, System } from 'entityx-ts'
|
|
2
|
-
// import { Touch } from '../../polyfills'
|
|
3
|
-
import { Container } from 'pixi.js'
|
|
4
|
-
|
|
5
|
-
import { NodeComp } from '../components/NodeComp'
|
|
6
|
-
import { ExtraDataComp, TouchEventRegister } from './NoRenderComponent'
|
|
7
|
-
import { Touch } from './Touch'
|
|
8
|
-
|
|
9
|
-
export class NoRenderSystem implements System {
|
|
10
|
-
configure(event_manager: EventManager) {
|
|
11
|
-
event_manager.subscribe(EventTypes.ComponentAdded, ExtraDataComp, ({ component }) => {
|
|
12
|
-
const { key, value } = component.props
|
|
13
|
-
component.data[key] = value
|
|
14
|
-
})
|
|
15
|
-
event_manager.subscribe(EventTypes.ComponentAdded, TouchEventRegister, ({ entity, component }) => {
|
|
16
|
-
const ett = entity
|
|
17
|
-
const touchComp = component
|
|
18
|
-
const nodeComp = ett.getComponent(NodeComp)
|
|
19
|
-
touchComp.node = nodeComp
|
|
20
|
-
const container: Container = nodeComp.instance
|
|
21
|
-
if (touchComp.props.onTouchStart) {
|
|
22
|
-
container.on('pointerdown', (event) => {
|
|
23
|
-
touchComp.props.onTouchStart(new Touch(event), nodeComp)
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
if (touchComp.props.onTouchMove) {
|
|
27
|
-
container.on('pointermove', (event) => {
|
|
28
|
-
touchComp.props.onTouchMove(new Touch(event), nodeComp)
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
if (touchComp.props.onTouchEnd) {
|
|
32
|
-
container.on('pointerup', (event) => {
|
|
33
|
-
touchComp.props.onTouchEnd(new Touch(event), nodeComp)
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
if (touchComp.props.onTouchEnd) {
|
|
37
|
-
container.on('pointercancel', (event) => {
|
|
38
|
-
touchComp.props.onTouchEnd(new Touch(event), nodeComp)
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
event_manager.subscribe(EventTypes.ComponentRemoved, TouchEventRegister, ({ component }) => {
|
|
43
|
-
console.log('ComponentRemovedEvent TouchEventRegister', event)
|
|
44
|
-
// const ett = event.entity
|
|
45
|
-
// const nodeComp = ett.getComponent(NodeComp)
|
|
46
|
-
const touchComp = component as TouchEventRegister
|
|
47
|
-
const container: Container = touchComp.node.instance
|
|
48
|
-
if (touchComp.props.onTouchStart) {
|
|
49
|
-
container.removeListener('touchstart')
|
|
50
|
-
}
|
|
51
|
-
if (touchComp.props.onTouchMove) {
|
|
52
|
-
container.removeListener('touchmove')
|
|
53
|
-
}
|
|
54
|
-
if (touchComp.props.onTouchEnd) {
|
|
55
|
-
container.removeListener('touchend')
|
|
56
|
-
}
|
|
57
|
-
if (touchComp.props.onTouchEnd) {
|
|
58
|
-
container.removeListener('touchcancel')
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// update(entities: EntityManager, events: EventManager, dt: number)
|
|
64
|
-
// update() {
|
|
65
|
-
// throw new Error('Method not implemented.');
|
|
66
|
-
// }
|
|
67
|
-
}
|
package/src/norender/Touch.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { FederatedPointerEvent } from 'pixi.js'
|
|
2
|
-
|
|
3
|
-
import { Vec2 } from '..'
|
|
4
|
-
|
|
5
|
-
export class Touch {
|
|
6
|
-
private event: FederatedPointerEvent
|
|
7
|
-
constructor(event) {
|
|
8
|
-
this.event = event
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
getLocation(): ReturnType<typeof Vec2> {
|
|
12
|
-
return Vec2(this.event.global)
|
|
13
|
-
}
|
|
14
|
-
getLocationX() {
|
|
15
|
-
return this.event.globalX
|
|
16
|
-
}
|
|
17
|
-
getLocationY() {
|
|
18
|
-
return this.event.globalY
|
|
19
|
-
}
|
|
20
|
-
getDelta(): ReturnType<typeof Vec2> {
|
|
21
|
-
return Vec2(this.event.movementX, this.event.movementY)
|
|
22
|
-
}
|
|
23
|
-
getDeltaX() {
|
|
24
|
-
return this.event.movementX
|
|
25
|
-
}
|
|
26
|
-
getDeltaY() {
|
|
27
|
-
return this.event.movementY
|
|
28
|
-
}
|
|
29
|
-
getLocationInView(view: any) {
|
|
30
|
-
const { x, y } = this.event.global
|
|
31
|
-
return view.toLocal({ x, y })
|
|
32
|
-
}
|
|
33
|
-
getLocationInNode(node: any) {
|
|
34
|
-
const { x, y } = this.event.global
|
|
35
|
-
return node.toLocal({ x, y })
|
|
36
|
-
}
|
|
37
|
-
}
|