@safe-engine/cocos 2.6.4 → 2.6.7
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 +124 -2
- package/dist/core/NodeComp.d.ts +4 -1
- package/dist/core/NodeComp.d.ts.map +1 -1
- package/dist/core/NodeComp.js +12 -1
- package/dist/dragonbones/DragonBonesSystem.js +3 -3
- package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -1
- package/dist/dragonbones/db-cocos/CocosFactory.js +2 -1
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +2 -2
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -1
- package/dist/dragonbones/db-cocos/SimpleMeshNode.js +1 -1
- package/dist/gui/GUIComponent.d.ts +1 -0
- package/dist/gui/GUIComponent.d.ts.map +1 -1
- package/dist/gui/GUISystem.js +2 -2
- package/dist/gui/SliderComp.d.ts +16 -0
- package/dist/gui/SliderComp.d.ts.map +1 -0
- package/dist/gui/SliderComp.js +32 -0
- package/dist/render/RenderTextureComp.d.ts +10 -0
- package/dist/render/RenderTextureComp.d.ts.map +1 -0
- package/dist/render/RenderTextureComp.js +13 -0
- package/dist/richtext/RichTextComp.d.ts +1 -0
- package/dist/richtext/RichTextComp.d.ts.map +1 -1
- package/dist/richtext/RichTextSystem.js +4 -4
- package/package.json +3 -3
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts +0 -9
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +0 -1
- package/dist/dragonbones/PixiDragonBonesSprite.js +0 -82
- package/dist/safex.d.ts +0 -10
- package/dist/safex.d.ts.map +0 -1
- package/dist/safex.js +0 -25
- package/dist/spine/CCSkeleton.d.ts +0 -189
- package/dist/spine/CCSkeleton.d.ts.map +0 -1
- package/dist/spine/CCSkeleton.js +0 -320
- package/dist/spine/CCSkeletonAnimation.d.ts +0 -146
- package/dist/spine/CCSkeletonAnimation.d.ts.map +0 -1
- package/dist/spine/CCSkeletonAnimation.js +0 -311
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +0 -2
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +0 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +0 -228
- package/dist/spine/CCSkeletonTexture.d.ts +0 -25
- package/dist/spine/CCSkeletonTexture.d.ts.map +0 -1
- package/dist/spine/CCSkeletonTexture.js +0 -60
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +0 -28
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +0 -1
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +0 -277
package/README.md
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Safex = JSX + cocos2x html5 Game Engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Safex is an game engine written in TypeScript, combining the power of JSX syntax with the renowned cocos2x html5 rendering library. This project aims to help mobile game developers build games quickly, easily, and intuitively.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **JSX Syntax:** Write UI and game logic in a React-like style for better code organization and readability.
|
|
10
|
+
- **Powered by Cocos2x html5:** Utilize for high-performance 2D rendering.
|
|
11
|
+
- **Component-based Architecture:** Easily manage game elements such as scenes, sprites, events, actions and animations.
|
|
12
|
+
- **Asset Loading Support:** Quickly load images, sounds, and sprite sheets.
|
|
13
|
+
- All components must be extends from `ComponentX` or call `registerSystem(${className})`
|
|
14
|
+
- `node` property represent node, and can pass properties to assign
|
|
15
|
+
- Example `<SpriteRender node={{ xy: [5, 9] }} />`
|
|
16
|
+
- `$ref` bind component with current class property as string
|
|
17
|
+
- `$push` push component to list
|
|
18
|
+
- `$refNode` and `$pushNode` for `NodeComp` component from any component.
|
|
19
|
+
- `Array(2).map(_, i)` iteration repeat component 2 times
|
|
20
|
+
- `Loading.listItems.map(item, i = 1)` iteration in class static readonly property
|
|
21
|
+
|
|
22
|
+
## Benefits
|
|
23
|
+
|
|
24
|
+
- **Rapid Development:** JSX makes writing code clean and intuitive.
|
|
25
|
+
- **Extensibility:** Easily add new features and functionalities.
|
|
26
|
+
- **Web Developer Friendly:** If you're familiar with React, you'll quickly get up to speed with Safex.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @safe-engine/cocos
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Basic Example
|
|
35
|
+
|
|
36
|
+
```tsx GameScene.tsx
|
|
37
|
+
import { SceneComponent, LabelComp, ButtonComp, SpriteRender, instantiate, Touch } from '@safe-engine/cocos'
|
|
38
|
+
import ColliderSprite from './ColliderSprite'
|
|
39
|
+
import { sf_sprite } from '../assets'
|
|
40
|
+
|
|
41
|
+
export class GameScene extends SceneComponent {
|
|
42
|
+
sprite: SpriteRender
|
|
43
|
+
label: LabelComp
|
|
44
|
+
|
|
45
|
+
onPress(target: ButtonComp) {
|
|
46
|
+
this.sprite.spriteFrame = 'other.sprite.png'
|
|
47
|
+
this.label.string = target.node.name
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
onTouchMove(event: Touch) {
|
|
51
|
+
const {x,y} = event.getLocation()
|
|
52
|
+
const sprite = instantiate(ColliderSprite)
|
|
53
|
+
sprite.node.posX = x
|
|
54
|
+
sprite.node.posY = y
|
|
55
|
+
this.node.addChild(sprite)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
return (
|
|
60
|
+
<SceneComponent>
|
|
61
|
+
<TouchEventRegister
|
|
62
|
+
onTouchMove={this.onTouchMove}
|
|
63
|
+
/>
|
|
64
|
+
<LabelComp $ref={this.label} node={{ xy: [106, 240] }} string="Hello safex" font={defaultFont} />
|
|
65
|
+
<ButtonComp $ref={this.sprite} node={{ xy: [500, 600], name: 'sf_sprite' }} spriteFrame={sf_sprite} onPress={this.onPress} >
|
|
66
|
+
</ButtonComp>
|
|
67
|
+
</SceneComponent>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Collider Events
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { ComponentX, SpriteRender } from '@safe-engine/cocos'
|
|
77
|
+
import { BoxCollider } from '@safe-engine/cocos/dist/collider'
|
|
78
|
+
import { sf_crash } from '../assets'
|
|
79
|
+
|
|
80
|
+
export class ColliderSprite extends ComponentX {
|
|
81
|
+
onCollisionEnter(other: Collider) {
|
|
82
|
+
console.log(other.props.tag)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
render() {
|
|
86
|
+
return (
|
|
87
|
+
<SpriteRender node={{ xy: [640, 360] }} spriteFrame={sf_crash}>
|
|
88
|
+
<BoxCollider height={100} width={100} onCollisionEnter={this.onCollisionEnter} tag={3} />
|
|
89
|
+
</SpriteRender>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Physics Events
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { ComponentX, SpriteRender } from '@safe-engine/cocos'
|
|
99
|
+
import { DynamicBody, PhysicsBoxCollider, RigidBody } from '@safe-engine/cocos/dist/box2d-wasm'
|
|
100
|
+
import { sf_crash } from '../assets'
|
|
101
|
+
|
|
102
|
+
export class PhysicsCollider extends ComponentX {
|
|
103
|
+
onBeginContact(other: RigidBody) {
|
|
104
|
+
console.log('onBeginContact', other)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
render() {
|
|
108
|
+
return (
|
|
109
|
+
<SpriteRender node={{ xy: [640, 360] }} spriteFrame={sf_crash}>
|
|
110
|
+
<RigidBody type={DynamicBody} onBeginContact={this.onBeginContact} tag={2} isSensor ></RigidBody>
|
|
111
|
+
<PhysicsBoxCollider height={100} width={100}></PhysicsBoxCollider>
|
|
112
|
+
</SpriteRender>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Contributing
|
|
119
|
+
|
|
120
|
+
We welcome all contributions! If you have ideas or want to improve the engine, feel free to create an issue or submit a pull request on GitHub.
|
|
121
|
+
|
|
122
|
+
## Contact
|
|
123
|
+
- [Discord](https://discord.com/channels/1344214207268388979/1344214208044208140)
|
|
124
|
+
|
|
125
|
+
Let's build a powerful and convenient game engine together! 🚀
|
package/dist/core/NodeComp.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare class NodeComp<C extends cc.Node = cc.Node> {
|
|
|
8
8
|
instance: C;
|
|
9
9
|
parent: NodeComp;
|
|
10
10
|
children: NodeComp[];
|
|
11
|
-
name: string;
|
|
12
11
|
private _active;
|
|
13
12
|
constructor(instance: C, entity: Entity);
|
|
14
13
|
get uuid(): number;
|
|
@@ -57,6 +56,10 @@ export declare class NodeComp<C extends cc.Node = cc.Node> {
|
|
|
57
56
|
set h(val: number);
|
|
58
57
|
get zIndex(): number;
|
|
59
58
|
set zIndex(val: number);
|
|
59
|
+
get name(): string;
|
|
60
|
+
set name(val: string);
|
|
61
|
+
get tag(): number;
|
|
62
|
+
set tag(val: number);
|
|
60
63
|
get childrenCount(): number;
|
|
61
64
|
destroy(): void;
|
|
62
65
|
addComponent<T extends ComponentType>(instance: T & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/core/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGhD,OAAO,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,IAAI,IA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EAAE,OAAO;IAMnC,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAM1B,OAAO,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IASjE,IAAI,KAAK,kBAMR;IAED,UAAU,CAAC,GAAG,EAAE,MAAM;IAOtB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC;CAOhE"}
|
package/dist/core/NodeComp.js
CHANGED
|
@@ -6,7 +6,6 @@ export class NodeComp {
|
|
|
6
6
|
instance;
|
|
7
7
|
parent;
|
|
8
8
|
children = [];
|
|
9
|
-
name;
|
|
10
9
|
_active = true;
|
|
11
10
|
constructor(instance, entity) {
|
|
12
11
|
this.entity = entity;
|
|
@@ -137,6 +136,18 @@ export class NodeComp {
|
|
|
137
136
|
set zIndex(val) {
|
|
138
137
|
this.instance.zIndex = val;
|
|
139
138
|
}
|
|
139
|
+
get name() {
|
|
140
|
+
return this.instance.getName();
|
|
141
|
+
}
|
|
142
|
+
set name(val) {
|
|
143
|
+
this.instance.setName(val);
|
|
144
|
+
}
|
|
145
|
+
get tag() {
|
|
146
|
+
return this.instance.getTag();
|
|
147
|
+
}
|
|
148
|
+
set tag(val) {
|
|
149
|
+
this.instance.setTag(val);
|
|
150
|
+
}
|
|
140
151
|
get childrenCount() {
|
|
141
152
|
return this.children.length;
|
|
142
153
|
}
|
|
@@ -35,17 +35,17 @@ export class DragonBonesSystem {
|
|
|
35
35
|
if (dbComp.props.onAnimationStart)
|
|
36
36
|
node.armature.eventDispatcher.addDBEventListener(EventObject.START, (event) => {
|
|
37
37
|
if (dbComp.node.active && dbComp.enabled)
|
|
38
|
-
dbComp.props.onAnimationStart(event.animationState
|
|
38
|
+
dbComp.props.onAnimationStart(event.animationState?.name);
|
|
39
39
|
}, dbComp);
|
|
40
40
|
if (dbComp.props.onAnimationEnd)
|
|
41
41
|
node.armature.eventDispatcher.addDBEventListener(EventObject.COMPLETE, (event) => {
|
|
42
42
|
if (dbComp.node.active && dbComp.enabled)
|
|
43
|
-
dbComp.props.onAnimationEnd(event.animationState
|
|
43
|
+
dbComp.props.onAnimationEnd(event.animationState?.name);
|
|
44
44
|
}, dbComp);
|
|
45
45
|
if (dbComp.props.onAnimationComplete)
|
|
46
46
|
node.armature.eventDispatcher.addDBEventListener(EventObject.LOOP_COMPLETE, (event) => {
|
|
47
47
|
if (dbComp.node.active && dbComp.enabled)
|
|
48
|
-
dbComp.props.onAnimationComplete(event.animationState
|
|
48
|
+
dbComp.props.onAnimationComplete(event.animationState?.name, event.animationState?.currentPlayTimes);
|
|
49
49
|
}, dbComp);
|
|
50
50
|
});
|
|
51
51
|
event_manager.subscribe(EventTypes.ComponentRemoved, DragonBonesComp, ({ component }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CocosFactory.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,QAAQ,EACR,WAAW,EAEX,oBAAoB,EACpB,UAAU,EACV,WAAW,EAEX,IAAI,EACJ,QAAQ,EACT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,EAAE,qBAAqB,EAAoB,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"CocosFactory.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,QAAQ,EACR,WAAW,EAEX,oBAAoB,EACpB,UAAU,EACV,WAAW,EAEX,IAAI,EACJ,QAAQ,EACT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAA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ject, DragonBones, } from '@cocos/dragonbo
|
|
|
24
24
|
import { CocosArmatureDisplay } from './CocosArmatureDisplay';
|
|
25
25
|
import { CocosSlot } from './CocosSlot';
|
|
26
26
|
import { CocosTextureAtlasData } from './CocosTextureAtlasData';
|
|
27
|
+
import { SimpleMeshNode } from './SimpleMeshNode';
|
|
27
28
|
/**
|
|
28
29
|
* - The Cocos factory.
|
|
29
30
|
* @version DragonBones 3.0
|
|
@@ -104,7 +105,7 @@ export class CocosFactory extends BaseFactory {
|
|
|
104
105
|
}
|
|
105
106
|
_buildSlot(_dataPackage, slotData, armature) {
|
|
106
107
|
const slot = BaseObject.borrowObject(CocosSlot);
|
|
107
|
-
slot.init(slotData, armature, new cc.Sprite(), new
|
|
108
|
+
slot.init(slotData, armature, new cc.Sprite(), new SimpleMeshNode());
|
|
108
109
|
return slot;
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare class SimpleMeshNode extends cc.
|
|
1
|
+
export declare class SimpleMeshNode extends cc.Sprite {
|
|
2
2
|
_texture: any;
|
|
3
3
|
_vertices: Float32Array | null;
|
|
4
4
|
_uvs: Float32Array | null;
|
|
@@ -19,7 +19,7 @@ export declare class SimpleMeshNode extends cc.Node {
|
|
|
19
19
|
setIndices(inds: Uint16Array): void;
|
|
20
20
|
setTexture(tex: cc.Texture2D): void;
|
|
21
21
|
setSpriteFrame(renderTexture: any): void;
|
|
22
|
-
visit(ctx?:
|
|
22
|
+
visit(ctx?: cc.Node): void;
|
|
23
23
|
_drawMesh(): void;
|
|
24
24
|
_ensureGL(): void;
|
|
25
25
|
_computeModelMatrixFromNode(): Float32Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleMeshNode.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/SimpleMeshNode.ts"],"names":[],"mappings":"AAOA,qBAAa,cAAe,SAAQ,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"S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C,CAAC,EAAE,MAAM,GAAG,IAAI;IAKzB,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;IAU5G,MAAM,IAAI,IAAI;CAcf"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Usage:
|
|
5
5
|
// const node = new SimpleMeshNode(texture, verts, uvs, inds);
|
|
6
6
|
// node.setPosition(x,y); node.setRotation(angleDeg); node.setScale(s);
|
|
7
|
-
export class SimpleMeshNode extends cc.
|
|
7
|
+
export class SimpleMeshNode extends cc.Sprite {
|
|
8
8
|
// public mesh data (Float32Array / Uint16Array)
|
|
9
9
|
_texture = null;
|
|
10
10
|
_vertices = null;
|
|
@@ -36,6 +36,7 @@ interface LabelCompProps {
|
|
|
36
36
|
size?: number;
|
|
37
37
|
outline?: [ColorSource, number];
|
|
38
38
|
shadow?: [ColorSource, number, Size];
|
|
39
|
+
isAdaptWithSize?: boolean;
|
|
39
40
|
}
|
|
40
41
|
export declare class LabelComp extends ComponentX<LabelCompProps & BaseComponentProps<LabelComp>, ccui.Text> {
|
|
41
42
|
get string(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GUIComponent.d.ts","sourceRoot":"","sources":["../../src/gui/GUIComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AACpD,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEzC,eAAO,MAAM,QAAQ;;;;CAIpB,CAAA;AAID,UAAU,eAAe;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,C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AAU,eAAe;IACvB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AACD,qBAAa,UAAW,SAAQ,UAAU,CAAC,eAAe,GAAG,kBAAkB,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;CAAG;AAExG,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AACD,qBAAa,cAAe,SAAQ,UAAU,CAAC,mBAAmB,GAAG,kBAAkB,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;IAC/G,KAAK;IAIL,QAAQ;CAWT"}
|
package/dist/gui/GUISystem.js
CHANGED
|
@@ -54,7 +54,7 @@ export class GUISystem {
|
|
|
54
54
|
bar.node = entity.assign(new NodeComp(pTimer, entity));
|
|
55
55
|
};
|
|
56
56
|
onAddLabelComp = ({ entity, component: label }) => {
|
|
57
|
-
const { string = '', font = GUISystem.defaultFont, size = 64, outline, shadow } = label.props;
|
|
57
|
+
const { string = '', font = GUISystem.defaultFont, size = 64, outline, shadow, isAdaptWithSize } = label.props;
|
|
58
58
|
const fontName = cc.path.basename(font, '.ttf');
|
|
59
59
|
const node = new ccui.Text(string, fontName, size);
|
|
60
60
|
node.setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM);
|
|
@@ -66,7 +66,7 @@ export class GUISystem {
|
|
|
66
66
|
const [color, blur, offset] = shadow;
|
|
67
67
|
node.enableShadow(color, offset, blur);
|
|
68
68
|
}
|
|
69
|
-
node.ignoreContentAdaptWithSize(
|
|
69
|
+
node.ignoreContentAdaptWithSize(!isAdaptWithSize);
|
|
70
70
|
label.node = entity.assign(new NodeComp(node, entity));
|
|
71
71
|
};
|
|
72
72
|
onAddScrollViewComp = ({ entity, component: scrollView }) => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseComponentProps, ComponentX } from '..';
|
|
2
|
+
interface SliderCompProps extends BaseComponentProps<SliderComp> {
|
|
3
|
+
barBackground: string;
|
|
4
|
+
normalBall: string;
|
|
5
|
+
pressedBall?: string;
|
|
6
|
+
disabledBall?: string;
|
|
7
|
+
percent?: number;
|
|
8
|
+
onChange: (percent: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class SliderComp extends ComponentX<SliderCompProps, ccui.Slider> {
|
|
11
|
+
set percent(val: number);
|
|
12
|
+
get percent(): number;
|
|
13
|
+
render(): this;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=SliderComp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderComp.d.ts","sourceRoot":"","sources":["../../src/gui/SliderComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAuC,MAAM,IAAI,CAAA;AAExF,UAAU,eAAgB,SAAQ,kBAAkB,CAAC,UAAU,CAAC;IAC9D,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAED,qBAAa,UAAW,SAAQ,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC;IACtE,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,EAEtB;IACD,IAAI,OAAO,IAAI,MAAM,CAEpB;IACD,MAAM;CAqBP"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentX, GameWorld, NodeComp, registerSystem } from '..';
|
|
2
|
+
export class SliderComp extends ComponentX {
|
|
3
|
+
set percent(val) {
|
|
4
|
+
this.node.instance.setPercent(val);
|
|
5
|
+
}
|
|
6
|
+
get percent() {
|
|
7
|
+
return this.node.instance.getPercent();
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
const { barBackground, normalBall, pressedBall, disabledBall, percent } = this.props;
|
|
11
|
+
const frame = cc.spriteFrameCache.getSpriteFrame(normalBall);
|
|
12
|
+
const textureType = !frame ? ccui.Widget.LOCAL_TEXTURE : ccui.Widget.PLIST_TEXTURE;
|
|
13
|
+
const slider = new ccui.Slider(barBackground, normalBall, textureType);
|
|
14
|
+
slider.loadSlidBallTexturePressed(pressedBall || normalBall, textureType);
|
|
15
|
+
slider.loadSlidBallTextureDisabled(disabledBall || normalBall, textureType);
|
|
16
|
+
if (percent !== undefined)
|
|
17
|
+
slider.setPercent(percent);
|
|
18
|
+
slider.addEventListener((sender, type) => {
|
|
19
|
+
// console.log('SliderComp onChange', type, sender)
|
|
20
|
+
if (type === ccui.Slider.EVENT_PERCENT_CHANGED) {
|
|
21
|
+
const percent = sender.getPercent();
|
|
22
|
+
this.props.onChange(percent);
|
|
23
|
+
}
|
|
24
|
+
}, this);
|
|
25
|
+
const world = GameWorld.Instance;
|
|
26
|
+
const entity = world.entities.create();
|
|
27
|
+
this.node = entity.assign(new NodeComp(slider, entity));
|
|
28
|
+
const comp = entity.assign(this);
|
|
29
|
+
return comp;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
registerSystem(SliderComp);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseComponentProps, ComponentX } from '..';
|
|
2
|
+
interface RenderTextureCompProps extends BaseComponentProps<RenderTextureComp> {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class RenderTextureComp extends ComponentX<RenderTextureCompProps, cc.RenderTexture> {
|
|
7
|
+
render(): this;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=RenderTextureComp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderTextureComp.d.ts","sourceRoot":"","sources":["../../src/render/RenderTextureComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAuC,MAAM,IAAI,CAAA;AAExF,UAAU,sBAAuB,SAAQ,kBAAkB,CAAC,iBAAiB,CAAC;IAC5E,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,sBAAsB,EAAE,EAAE,CAAC,aAAa,CAAC;IACzF,MAAM;CAUP"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentX, GameWorld, NodeComp, registerSystem } from '..';
|
|
2
|
+
export class RenderTextureComp extends ComponentX {
|
|
3
|
+
render() {
|
|
4
|
+
const { width, height } = this.props;
|
|
5
|
+
const rt = new cc.RenderTexture(width, height);
|
|
6
|
+
const world = GameWorld.Instance;
|
|
7
|
+
const entity = world.entities.create();
|
|
8
|
+
this.node = entity.assign(new NodeComp(rt, entity));
|
|
9
|
+
const comp = entity.assign(this);
|
|
10
|
+
return comp;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
registerSystem(RenderTextureComp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextComp.d.ts","sourceRoot":"","sources":["../../src/richtext/RichTextComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAa,MAAM,IAAI,CAAA;AAClD,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AAKtD,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"RichTextComp.d.ts","sourceRoot":"","sources":["../../src/richtext/RichTextComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAa,MAAM,IAAI,CAAA;AAClD,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AAKtD,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAC/G,IAAI,MAAM,IAIM,MAAM,CAFrB;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAyBrB;CACF"}
|
|
@@ -6,11 +6,11 @@ export class RichTextSystem {
|
|
|
6
6
|
event_manager.subscribe(EventTypes.ComponentAdded, RichTextComp, this.onAddRichTextComp);
|
|
7
7
|
}
|
|
8
8
|
onAddRichTextComp = ({ entity, component: rich }) => {
|
|
9
|
-
const { string = '' } = rich.props;
|
|
9
|
+
const { string = '', isAdaptWithSize } = rich.props;
|
|
10
10
|
const node = new ccui.RichText();
|
|
11
|
-
node.width = 500
|
|
12
|
-
node.height = 300
|
|
13
|
-
node.ignoreContentAdaptWithSize(
|
|
11
|
+
// node.width = 500
|
|
12
|
+
// node.height = 300
|
|
13
|
+
node.ignoreContentAdaptWithSize(!isAdaptWithSize);
|
|
14
14
|
rich.node = entity.assign(new NodeComp(node, entity));
|
|
15
15
|
rich.string = string;
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/cocos",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"description": "safe-engine with cocos renderer support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@cocos/dragonbones-js": "^1.0.2",
|
|
25
|
-
"@esotericsoftware/spine-core": "^4.2.
|
|
25
|
+
"@esotericsoftware/spine-core": "^4.2.104",
|
|
26
26
|
"box2d-wasm": "^7.0.0",
|
|
27
|
-
"cocos-html5-ts": "^2.1.
|
|
27
|
+
"cocos-html5-ts": "^2.1.11",
|
|
28
28
|
"entityx-ts": "^2.3.1"
|
|
29
29
|
},
|
|
30
30
|
"author": "",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const SharedDragonBonesManager: {
|
|
2
|
-
isLoaded: boolean;
|
|
3
|
-
factory: any;
|
|
4
|
-
assets: {};
|
|
5
|
-
loadAssetsOnce: (key: any, texJsonUrl: any, texPngUrl: any) => void;
|
|
6
|
-
buildArmatureDisplay: (key: any) => any;
|
|
7
|
-
};
|
|
8
|
-
export declare const PixiDragonBonesSprite: any;
|
|
9
|
-
//# sourceMappingURL=PixiDragonBonesSprite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PixiDragonBonesSprite.d.ts","sourceRoot":"","sources":["../../src/dragonbones/PixiDragonBonesSprite.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB;;;;;;CA8BpC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,GA+DlC,CAAA"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export const SharedDragonBonesManager = {
|
|
2
|
-
isLoaded: false,
|
|
3
|
-
factory: dragonBones.PixiFactory.factory,
|
|
4
|
-
assets: {},
|
|
5
|
-
loadAssetsOnce: function (key, texJsonUrl, texPngUrl) {
|
|
6
|
-
if (this.assets[key]) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const loader = new PIXI.Loader();
|
|
10
|
-
loader
|
|
11
|
-
.add(`ske${key}`, key)
|
|
12
|
-
.add(`texJson${key}`, texJsonUrl)
|
|
13
|
-
.add(`texPng${key}`, texPngUrl)
|
|
14
|
-
.load((loader, resources) => {
|
|
15
|
-
const dragonData = this.factory.parseDragonBonesData(resources[`ske${key}`].data, key);
|
|
16
|
-
this.factory.parseTextureAtlasData(resources[`texJson${key}`].data, resources[`texPng${key}`].texture, key);
|
|
17
|
-
this.assets[key] = {
|
|
18
|
-
dragonData,
|
|
19
|
-
texture: resources[`texPng${key}`].texture,
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
buildArmatureDisplay: function (key) {
|
|
24
|
-
// console.log(this.assets[key])
|
|
25
|
-
const { armatureNames } = this.assets[key].dragonData;
|
|
26
|
-
const armatureName = armatureNames[0];
|
|
27
|
-
return this.factory.buildArmatureDisplay(armatureName, key);
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
export const PixiDragonBonesSprite = cc.Sprite.extend({
|
|
31
|
-
ctor: function (config) {
|
|
32
|
-
this._super();
|
|
33
|
-
this._canvas = document.createElement('canvas');
|
|
34
|
-
this._canvas.width = config.width || 1024;
|
|
35
|
-
this._canvas.height = config.height || 1024;
|
|
36
|
-
this._pixiApp = new PIXI.Application({
|
|
37
|
-
view: this._canvas,
|
|
38
|
-
width: this._canvas.width,
|
|
39
|
-
height: this._canvas.height,
|
|
40
|
-
backgroundAlpha: 0, // nền trong suốt
|
|
41
|
-
transparent: true, // bắt buộc để alpha hoạt động
|
|
42
|
-
clearBeforeRender: true, // xoá trước khi vẽ frame mới
|
|
43
|
-
preserveDrawingBuffer: true, // giúp lấy ảnh từ canvas
|
|
44
|
-
antialias: true,
|
|
45
|
-
});
|
|
46
|
-
this._texture = new cc.Texture2D();
|
|
47
|
-
this._texture.initWithElement(this._canvas);
|
|
48
|
-
this._texture.handleLoadedTexture();
|
|
49
|
-
this.initWithTexture(this._texture);
|
|
50
|
-
this._config = config;
|
|
51
|
-
this._armatureDisplay = null;
|
|
52
|
-
this._setupArmature();
|
|
53
|
-
// this.schedule(this.updateTexture, 1 / 30);
|
|
54
|
-
},
|
|
55
|
-
_setupArmature: function () {
|
|
56
|
-
const display = SharedDragonBonesManager.buildArmatureDisplay(this._config.ske);
|
|
57
|
-
if (!display) {
|
|
58
|
-
console.error('Không thể build armature:', this._config.armatureName);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
display.animation.play(this._config.animationName, 0, this._config.playTimes);
|
|
62
|
-
display.x = this._canvas.width / 2;
|
|
63
|
-
display.y = this._canvas.height / 2;
|
|
64
|
-
display.scale.set(this._config.scale || 1);
|
|
65
|
-
this._pixiApp.stage.addChild(display);
|
|
66
|
-
this._armatureDisplay = display;
|
|
67
|
-
},
|
|
68
|
-
updateTexture: function () {
|
|
69
|
-
if (this._armatureDisplay) {
|
|
70
|
-
this._pixiApp.renderer.render(this._pixiApp.stage);
|
|
71
|
-
this._texture.initWithElement(this._canvas);
|
|
72
|
-
this._texture.handleLoadedTexture();
|
|
73
|
-
this.setTexture(this._texture);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
onExit: function () {
|
|
77
|
-
// this.unschedule(this.updateTexture);
|
|
78
|
-
this._pixiApp.destroy(true, { children: true });
|
|
79
|
-
this._canvas.remove();
|
|
80
|
-
this._super();
|
|
81
|
-
},
|
|
82
|
-
});
|
package/dist/safex.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Color4B, NodeComp } from '.';
|
|
2
|
-
export type ColorSource = ReturnType<typeof Color4B>;
|
|
3
|
-
export interface BaseComponentProps<T> {
|
|
4
|
-
$ref?: T;
|
|
5
|
-
$push?: T[];
|
|
6
|
-
$refNode?: NodeComp;
|
|
7
|
-
$pushNode?: NodeComp[];
|
|
8
|
-
node?: Partial<NodeComp>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=safex.d.ts.map
|
package/dist/safex.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safex.d.ts","sourceRoot":"","sources":["../src/safex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;AAErC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAA;AAEpD,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;CAEzB"}
|
package/dist/safex.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
// interface LoadingBarProps {}
|
|
3
|
-
// interface PhysicsMaterialProps {
|
|
4
|
-
// friction?: number
|
|
5
|
-
// restitution?: number
|
|
6
|
-
// density?: number
|
|
7
|
-
// }
|
|
8
|
-
// interface ColliderPhysicsProps {
|
|
9
|
-
// tag?: number
|
|
10
|
-
// group?: number
|
|
11
|
-
// offset?: Vec2
|
|
12
|
-
// onCollisionEnter?: (other: Collider) => void
|
|
13
|
-
// onCollisionExit?: (other: Collider) => void
|
|
14
|
-
// onCollisionStay?: (other: Collider) => void
|
|
15
|
-
// }
|
|
16
|
-
// interface BoxColliderPhysicsProps {
|
|
17
|
-
// width: number
|
|
18
|
-
// height: number
|
|
19
|
-
// }
|
|
20
|
-
// interface CircleColliderPhysicsProps {
|
|
21
|
-
// radius: number
|
|
22
|
-
// }
|
|
23
|
-
// interface PolygonColliderPhysicsProps {
|
|
24
|
-
// points: Array<Vec2>
|
|
25
|
-
// }
|