@safe-engine/pixi 1.0.1 → 1.0.2
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 +4 -4
- package/dist/components/NodeComp.d.ts +1 -1
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +1 -1
- package/dist/helper/utils.d.ts +1 -7
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +5 -25
- package/dist/systems/GUISystem.d.ts +1 -2
- package/dist/systems/GUISystem.d.ts.map +1 -1
- package/dist/systems/GUISystem.js +52 -73
- package/dist/systems/RenderSystem.d.ts +1 -2
- package/dist/systems/RenderSystem.d.ts.map +1 -1
- package/dist/systems/RenderSystem.js +47 -70
- package/package.json +2 -3
- package/.github/workflows/npm-publish.yml +0 -35
- package/dist/core/Vec2.d.ts +0 -20
- package/dist/core/Vec2.d.ts.map +0 -1
- package/dist/core/Vec2.js +0 -70
- package/src/app.ts +0 -51
- package/src/components/EnhancedComponent.ts +0 -57
- package/src/components/GUIComponent.ts +0 -146
- package/src/components/NodeComp.ts +0 -409
- package/src/components/RenderComponent.ts +0 -65
- package/src/core/Color.ts +0 -3
- package/src/core/LoadingBar.ts +0 -33
- package/src/core/Scene.ts +0 -17
- package/src/core/Size.ts +0 -21
- package/src/core/decorator.ts +0 -18
- package/src/gworld.ts +0 -17
- package/src/helper/html-text-parser.ts +0 -364
- package/src/helper/utils.ts +0 -64
- package/src/index.ts +0 -9
- package/src/systems/GUISystem.ts +0 -95
- package/src/systems/RenderSystem.ts +0 -100
- package/tsconfig.json +0 -24
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Guide
|
|
2
|
-
- components must be in `tsx` extension
|
|
3
|
-
- `$ref` bind with current class property as string
|
|
4
|
-
- every property start with `$` will reference to current class property as string
|
|
1
|
+
# Guide
|
|
2
|
+
- components must be in `tsx` extension
|
|
3
|
+
- `$ref` bind with current class property as string
|
|
4
|
+
- every property start with `$` will reference to current class property as string
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Constructor, Entity } from 'entityx-ts';
|
|
2
2
|
import { Color, ColorSource, Container, Point } from 'pixi.js';
|
|
3
3
|
import { Action, Animation } from 'pixi-action-ease';
|
|
4
|
-
import { Size } from '../helper/utils';
|
|
5
4
|
import { ComponentType, EnhancedComponent } from './EnhancedComponent';
|
|
5
|
+
import { Size } from '../core/Size';
|
|
6
6
|
export type EventCallbackType = (...args: any[]) => void;
|
|
7
7
|
export interface EventMap {
|
|
8
8
|
[key: string]: [EventCallbackType];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/components/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAC,MAAM,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAU,MAAM,SAAS,CAAA;AACtE,OAAO,EAAE,MAAM,EAAiB,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/components/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAC,MAAM,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAU,MAAM,SAAS,CAAA;AACtE,OAAO,EAAE,MAAM,EAAiB,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,OAAA,KAAK,IAAI,CAAA;AACjD,MAAM,WAAW,QAAQ;IACvB,CAAC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}
|
|
@@ -302,7 +302,7 @@ var NodeComp = /** @class */ (function () {
|
|
|
302
302
|
// return box
|
|
303
303
|
// }
|
|
304
304
|
NodeComp.prototype.getContentSize = function () {
|
|
305
|
-
return this.instance;
|
|
305
|
+
return this.instance.boundsArea;
|
|
306
306
|
};
|
|
307
307
|
// setContentSize(size: cc.Size | number, height?: number) {
|
|
308
308
|
// this.instance.setContentSize(size, height)
|
package/dist/helper/utils.d.ts
CHANGED
|
@@ -3,15 +3,9 @@ import { ComponentX } from '..';
|
|
|
3
3
|
export declare function registerSystem<T extends ComponentX>(component: Constructor<T>): {
|
|
4
4
|
new (): {
|
|
5
5
|
configure(event_manager: EventManager): void;
|
|
6
|
-
|
|
6
|
+
receiveComponentAddedEvent(event: EventReceive<T>): void;
|
|
7
7
|
update(entities: EntityManager, events: EventManager, dt: number): void;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
export declare function instantiate<T>(ComponentType: Constructor<T>, data?: any): T;
|
|
11
|
-
export declare class Size {
|
|
12
|
-
constructor(width: any, height: any);
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
}
|
|
16
|
-
export declare function size(width: number, height: number): Size;
|
|
17
11
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAGvD,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,UAAU,EAAY,MAAM,IAAI,CAAA;AAGzC,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;;iCAKjD,YAAY;0CAKH,YAAY,CAAC,CAAC,CAAC;yBAMhC,aAAa,UAAU,YAAY,MAAM,MAAM;;EAenE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAE3E"}
|
package/dist/helper/utils.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Size = void 0;
|
|
4
3
|
exports.registerSystem = registerSystem;
|
|
5
4
|
exports.instantiate = instantiate;
|
|
6
|
-
exports.size = size;
|
|
7
5
|
var entityx_ts_1 = require("entityx-ts");
|
|
8
6
|
var __1 = require("..");
|
|
9
7
|
var gworld_1 = require("../gworld");
|
|
@@ -16,19 +14,12 @@ function registerSystem(component) {
|
|
|
16
14
|
}
|
|
17
15
|
NewSystem.prototype.configure = function (event_manager) {
|
|
18
16
|
console.log('configure registerSystem', component.name);
|
|
19
|
-
event_manager.subscribe(
|
|
17
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, component, this.receiveComponentAddedEvent.bind(this));
|
|
20
18
|
};
|
|
21
|
-
NewSystem.prototype.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var newComp = ett.getComponent(component);
|
|
26
|
-
newComp.node = ett.getComponent(__1.NodeComp);
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
default:
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
19
|
+
NewSystem.prototype.receiveComponentAddedEvent = function (event) {
|
|
20
|
+
var ett = event.entity;
|
|
21
|
+
var newComp = ett.getComponent(component);
|
|
22
|
+
newComp.node = ett.getComponent(__1.NodeComp);
|
|
32
23
|
};
|
|
33
24
|
NewSystem.prototype.update = function (entities, events, dt) {
|
|
34
25
|
for (var _i = 0, _a = entities.entities_with_components(component); _i < _a.length; _i++) {
|
|
@@ -51,14 +42,3 @@ function registerSystem(component) {
|
|
|
51
42
|
function instantiate(ComponentType, data) {
|
|
52
43
|
return ComponentType.create(data);
|
|
53
44
|
}
|
|
54
|
-
var Size = /** @class */ (function () {
|
|
55
|
-
function Size(width, height) {
|
|
56
|
-
this.width = width;
|
|
57
|
-
this.height = height;
|
|
58
|
-
}
|
|
59
|
-
return Size;
|
|
60
|
-
}());
|
|
61
|
-
exports.Size = Size;
|
|
62
|
-
function size(width, height) {
|
|
63
|
-
return new Size(width, height);
|
|
64
|
-
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { EventManager,
|
|
1
|
+
import { EventManager, System } from 'entityx-ts';
|
|
2
2
|
export declare class GUISystem implements System {
|
|
3
3
|
configure(event_manager: EventManager): void;
|
|
4
|
-
receive(type: string, event: EventReceive): void;
|
|
5
4
|
update(): void;
|
|
6
5
|
}
|
|
7
6
|
//# sourceMappingURL=GUISystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GUISystem.d.ts","sourceRoot":"","sources":["../../src/systems/GUISystem.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"GUISystem.d.ts","sourceRoot":"","sources":["../../src/systems/GUISystem.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAEZ,MAAM,EACP,MAAM,YAAY,CAAA;AAQnB,qBAAa,SAAU,YAAW,MAAM;IACtC,SAAS,CAAC,aAAa,EAAE,YAAY;IAoDrC,MAAM;CAGP"}
|
|
@@ -12,79 +12,58 @@ var GUISystem = /** @class */ (function () {
|
|
|
12
12
|
function GUISystem() {
|
|
13
13
|
}
|
|
14
14
|
GUISystem.prototype.configure = function (event_manager) {
|
|
15
|
-
event_manager.subscribe(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.log('
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
node.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
scroll_1.node = ett.assign(new __1.NodeComp(view, ett));
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case (0, entityx_ts_1.ComponentAddedEvent)(GUIComponent_1.LabelComp): {
|
|
71
|
-
console.log('ComponentAddedEvent LabelComp', event);
|
|
72
|
-
var ett = event.entity;
|
|
73
|
-
var label = ett.getComponent(GUIComponent_1.LabelComp);
|
|
74
|
-
var node = new pixi_js_1.Text();
|
|
75
|
-
// node.texture.rotate = 8
|
|
76
|
-
node.style.fill = '#fff';
|
|
77
|
-
label.node = ett.assign(new __1.NodeComp(node, ett));
|
|
78
|
-
var _a = label.string, string = _a === void 0 ? '' : _a, _b = label.font, font = _b === void 0 ? '' : _b, size = label.size;
|
|
79
|
-
if (font)
|
|
80
|
-
label.setFont(font);
|
|
81
|
-
label.setSize(size);
|
|
82
|
-
label.setString(string);
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
default:
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
15
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.ButtonComp, function (_a) {
|
|
16
|
+
var entity = _a.entity, component = _a.component;
|
|
17
|
+
var nodeComp = entity.getComponent(__1.NodeComp);
|
|
18
|
+
// const { normalImage, selectedImage, disableImage, texType, zoomScale } = button
|
|
19
|
+
var node = new ui_1.Button(nodeComp.instance);
|
|
20
|
+
// node.setZoomScale(zoomScale - 1)
|
|
21
|
+
component.node = nodeComp;
|
|
22
|
+
// component.node = entity.assign(new NodeComp(node, entity))
|
|
23
|
+
node.onPress.connect(function () {
|
|
24
|
+
// console.log('onPress.connect')
|
|
25
|
+
var scale = pixi_action_ease_1.ScaleTo.create(0.12, 1.2);
|
|
26
|
+
var scaleDown = pixi_action_ease_1.ScaleTo.create(0.12, 1);
|
|
27
|
+
var seq = pixi_action_ease_1.Sequence.create(scale, pixi_action_ease_1.CallFunc.create(function () {
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(component, 'onPress')) {
|
|
29
|
+
component.onPress(component);
|
|
30
|
+
}
|
|
31
|
+
}), scaleDown);
|
|
32
|
+
var ease = pixi_action_ease_1.EaseBackIn.create(seq);
|
|
33
|
+
component.node.runAction(ease);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.ProgressBarComp, function (_a) {
|
|
37
|
+
var entity = _a.entity, component = _a.component;
|
|
38
|
+
var spriteComp = entity.getComponent(__1.SpriteRender);
|
|
39
|
+
if (!spriteComp)
|
|
40
|
+
throw Error('ProgressBarComp need SpriteRender');
|
|
41
|
+
var progress = component.progress, mode = component.mode;
|
|
42
|
+
var node = new LoadingBar_1.LoadingBar(mode, spriteComp.node.instance);
|
|
43
|
+
spriteComp.node.instance.mask = node;
|
|
44
|
+
component.node = entity.assign(new __1.NodeComp(node, entity));
|
|
45
|
+
node.progress = progress;
|
|
46
|
+
});
|
|
47
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.ScrollView, function (_a) {
|
|
48
|
+
var entity = _a.entity, component = _a.component;
|
|
49
|
+
var width = component.width, height = component.height;
|
|
50
|
+
var view = new ui_1.ScrollBox({ width: width, height: height });
|
|
51
|
+
component.node = entity.assign(new __1.NodeComp(view, entity));
|
|
52
|
+
});
|
|
53
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.LabelComp, function (_a) {
|
|
54
|
+
var entity = _a.entity, component = _a.component;
|
|
55
|
+
console.log('ComponentAddedEvent LabelComp', component);
|
|
56
|
+
var node = new pixi_js_1.Text();
|
|
57
|
+
// node.texture.rotate = 8
|
|
58
|
+
node.style.fill = '#fff';
|
|
59
|
+
component.node = entity.assign(new __1.NodeComp(node, entity));
|
|
60
|
+
var _b = component.string, string = _b === void 0 ? '' : _b, _c = component.font, font = _c === void 0 ? '' : _c, size = component.size;
|
|
61
|
+
if (font)
|
|
62
|
+
component.setFont(font);
|
|
63
|
+
component.setSize(size);
|
|
64
|
+
component.setString(string);
|
|
65
|
+
});
|
|
66
|
+
// event_manager.subscribe(EventTypes.ComponentAdded, BlockInputEventsComp), this);
|
|
88
67
|
};
|
|
89
68
|
GUISystem.prototype.update = function () {
|
|
90
69
|
// throw new Error('Method not implemented.');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventManager,
|
|
1
|
+
import { EventManager, System } from 'entityx-ts';
|
|
2
2
|
export declare enum SpriteTypes {
|
|
3
3
|
SIMPLE = 0,
|
|
4
4
|
SLICED = 1,
|
|
@@ -9,7 +9,6 @@ export declare enum SpriteTypes {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class RenderSystem implements System {
|
|
11
11
|
configure(event_manager: EventManager): void;
|
|
12
|
-
receive(type: string, event: EventReceive): void;
|
|
13
12
|
update(): void;
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=RenderSystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderSystem.d.ts","sourceRoot":"","sources":["../../src/systems/RenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RenderSystem.d.ts","sourceRoot":"","sources":["../../src/systems/RenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,MAAM,EACP,MAAM,YAAY,CAAA;AAOnB,oBAAY,WAAW;IACrB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED,qBAAa,YAAa,YAAW,MAAM;IACzC,SAAS,CAAC,aAAa,EAAE,YAAY;IA6CrC,MAAM;CAGP"}
|
|
@@ -19,78 +19,55 @@ var RenderSystem = /** @class */ (function () {
|
|
|
19
19
|
function RenderSystem() {
|
|
20
20
|
}
|
|
21
21
|
RenderSystem.prototype.configure = function (event_manager) {
|
|
22
|
-
event_manager.subscribe(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
event_manager.subscribe(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// console.log('
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// console.log('ComponentAddedEvent SpriteRender', event)
|
|
42
|
-
var ett = event.entity;
|
|
43
|
-
var spriteComp = ett.getComponent(RenderComponent_1.SpriteRender);
|
|
44
|
-
var spriteFrame = spriteComp.spriteFrame, type_1 = spriteComp.type, fillType = spriteComp.fillType, fillRange = spriteComp.fillRange, fillCenter = spriteComp.fillCenter;
|
|
45
|
-
var node = pixi_js_1.Sprite.from(spriteFrame);
|
|
46
|
-
if (type_1 === SpriteTypes.FILLED) {
|
|
47
|
-
// console.log('fillType', fillType)
|
|
48
|
-
var loadingBar = new LoadingBar_1.LoadingBar(fillType, node);
|
|
49
|
-
if (fillRange)
|
|
50
|
-
loadingBar.progress = fillRange;
|
|
51
|
-
if (fillCenter)
|
|
52
|
-
loadingBar.fillCenter = fillCenter;
|
|
53
|
-
spriteComp.loadingBar = loadingBar;
|
|
54
|
-
// node.setMidpoint(fillCenter)
|
|
55
|
-
}
|
|
56
|
-
// node.texture.rotate = 8
|
|
57
|
-
spriteComp.node = ett.assign(new __1.NodeComp(node, ett));
|
|
58
|
-
// spriteComp.node.anchorX = 0.5
|
|
59
|
-
// spriteComp.node.anchorY = 0.5
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
// case ComponentAddedEvent(MaskRender): {
|
|
63
|
-
// console.log('MaskRender', event.component);
|
|
64
|
-
// const ett = event.entity
|
|
65
|
-
// const maskComp = event.entity.getComponent(MaskRender)
|
|
66
|
-
// const { type, segments, inverted } = maskComp
|
|
67
|
-
// const node = new cc.ClippingNode()
|
|
68
|
-
// node.setInverted(inverted)
|
|
69
|
-
// maskComp.node = ett.assign(new NodeComp(node, ett))
|
|
70
|
-
// break
|
|
71
|
-
// }
|
|
72
|
-
case (0, entityx_ts_1.ComponentAddedEvent)(RenderComponent_1.GraphicsRender): {
|
|
73
|
-
console.log('MaskRender', event.component);
|
|
74
|
-
var ett = event.entity;
|
|
75
|
-
var graphics = event.entity.getComponent(RenderComponent_1.GraphicsRender);
|
|
76
|
-
var lineWidth = graphics.lineWidth, strokeColor = graphics.strokeColor, fillColor = graphics.fillColor;
|
|
77
|
-
var node = new pixi_js_1.Graphics();
|
|
78
|
-
node.beginFill(fillColor);
|
|
79
|
-
node.lineStyle(lineWidth, strokeColor);
|
|
80
|
-
graphics.node = ett.assign(new __1.NodeComp(node, ett));
|
|
81
|
-
// node.drawCircle(0, 0, 100)
|
|
82
|
-
break;
|
|
22
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, RenderComponent_1.NodeRender, function (_a) {
|
|
23
|
+
var entity = _a.entity;
|
|
24
|
+
var nodeRenderComp = entity.getComponent(RenderComponent_1.NodeRender);
|
|
25
|
+
var node = new pixi_js_1.Container();
|
|
26
|
+
nodeRenderComp.node = entity.assign(new __1.NodeComp(node, entity));
|
|
27
|
+
});
|
|
28
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, RenderComponent_1.SpriteRender, function (_a) {
|
|
29
|
+
var entity = _a.entity, component = _a.component;
|
|
30
|
+
var spriteFrame = component.spriteFrame, type = component.type, fillType = component.fillType, fillRange = component.fillRange, fillCenter = component.fillCenter;
|
|
31
|
+
var node = pixi_js_1.Sprite.from(spriteFrame);
|
|
32
|
+
if (type === SpriteTypes.FILLED) {
|
|
33
|
+
// console.log('fillType', fillType)
|
|
34
|
+
var loadingBar = new LoadingBar_1.LoadingBar(fillType, node);
|
|
35
|
+
if (fillRange)
|
|
36
|
+
loadingBar.progress = fillRange;
|
|
37
|
+
if (fillCenter)
|
|
38
|
+
loadingBar.fillCenter = fillCenter;
|
|
39
|
+
component.loadingBar = loadingBar;
|
|
40
|
+
// node.setMidpoint(fillCenter)
|
|
83
41
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
42
|
+
// node.texture.rotate = 8
|
|
43
|
+
component.node = entity.assign(new __1.NodeComp(node, entity));
|
|
44
|
+
// component.node.anchorX = 0.5
|
|
45
|
+
// component.node.anchorY = 0.5
|
|
46
|
+
});
|
|
47
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, RenderComponent_1.MaskRender, function (_a) {
|
|
48
|
+
var component = _a.component;
|
|
49
|
+
console.log('MaskRender', component);
|
|
50
|
+
// const { type, segments, inverted } = maskComp
|
|
51
|
+
// const node = new cc.ClippingNode()
|
|
52
|
+
// node.setInverted(inverted)
|
|
53
|
+
// maskComp.node = ett.assign(new NodeComp(node, ett))
|
|
54
|
+
});
|
|
55
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, RenderComponent_1.GraphicsRender, function (_a) {
|
|
56
|
+
var entity = _a.entity, component = _a.component;
|
|
57
|
+
var lineWidth = component.lineWidth, strokeColor = component.strokeColor, fillColor = component.fillColor;
|
|
58
|
+
var node = new pixi_js_1.Graphics();
|
|
59
|
+
node.fill(fillColor);
|
|
60
|
+
node.fillStyle = strokeColor;
|
|
61
|
+
node.width = lineWidth;
|
|
62
|
+
component.node = entity.assign(new __1.NodeComp(node, entity));
|
|
63
|
+
// node.drawCircle(0, 0, 100)
|
|
64
|
+
});
|
|
65
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentRemoved, __1.NodeComp, function (_a) {
|
|
66
|
+
var component = _a.component;
|
|
67
|
+
if (component) {
|
|
68
|
+
component.instance.removeFromParent();
|
|
90
69
|
}
|
|
91
|
-
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
70
|
+
});
|
|
94
71
|
};
|
|
95
72
|
RenderSystem.prototype.update = function () {
|
|
96
73
|
// throw new Error('Method not implemented.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/pixi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@pixi/ui": "^2.1.5",
|
|
20
|
-
"entityx-ts": "^
|
|
21
|
-
"howler-pixi-loader-middleware": "^5.0.0",
|
|
20
|
+
"entityx-ts": "^2.0.2",
|
|
22
21
|
"lodash": "^4.17.21",
|
|
23
22
|
"pixi-action-ease": "^1.0.12",
|
|
24
23
|
"pixi.js": "^8.4.0"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Publish NPM Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
workflow_dispatch: # Allows you to run this workflow manually
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
build:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
- uses: actions/setup-node@v3
|
|
17
|
-
with:
|
|
18
|
-
node-version: 20
|
|
19
|
-
- run: npm ci
|
|
20
|
-
- run: npm run build
|
|
21
|
-
|
|
22
|
-
publish-npm:
|
|
23
|
-
needs: build
|
|
24
|
-
runs-on: ubuntu-latest
|
|
25
|
-
steps:
|
|
26
|
-
- uses: actions/checkout@v4
|
|
27
|
-
- uses: actions/setup-node@v3
|
|
28
|
-
with:
|
|
29
|
-
node-version: 20
|
|
30
|
-
registry-url: https://registry.npmjs.org/
|
|
31
|
-
- run: npm ci
|
|
32
|
-
- run: npm run build
|
|
33
|
-
- run: npm publish
|
|
34
|
-
env:
|
|
35
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/dist/core/Vec2.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Point } from 'pixi.js';
|
|
2
|
-
declare class _Vec2 extends Point {
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
static ZERO: any;
|
|
6
|
-
equals(other: Point): boolean;
|
|
7
|
-
addSelf(value: Point): Point;
|
|
8
|
-
cross(other: Vec2): number;
|
|
9
|
-
signAngle(other: Vec2): number;
|
|
10
|
-
lengthSqr(): number;
|
|
11
|
-
dot(other: Vec2): number;
|
|
12
|
-
angle(other: Vec2): number;
|
|
13
|
-
}
|
|
14
|
-
export type Vec2 = _Vec2;
|
|
15
|
-
export declare function Vec2(x?: number, y?: number): Vec2;
|
|
16
|
-
export declare namespace Vec2 {
|
|
17
|
-
var ZERO: Readonly<_Vec2>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=Vec2.d.ts.map
|
package/dist/core/Vec2.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Vec2.d.ts","sourceRoot":"","sources":["../../src/core/Vec2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,cAAM,KAAM,SAAQ,KAAK;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,MAAM,CAAC,IAAI,MAAA;IAEX,MAAM,CAAC,KAAK,EAAE,KAAK;IAInB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;IAOrB,KAAK,CAAC,KAAK,EAAE,IAAI;IAGjB,SAAS,CAAC,KAAK,EAAE,IAAI;IAIrB,SAAS;IAGT,GAAG,CAAC,KAAK,EAAE,IAAI;IAGf,KAAK,CAAC,KAAK,EAAE,IAAI;CAczB;AACD,MAAM,MAAM,IAAI,GAAG,KAAK,CAAA;AACxB,wBAAgB,IAAI,CAAC,CAAC,SAAI,EAAE,CAAC,SAAI,GAAG,IAAI,CAEvC;yBAFe,IAAI"}
|
package/dist/core/Vec2.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.Vec2 = Vec2;
|
|
22
|
-
var clamp_1 = __importDefault(require("lodash/clamp"));
|
|
23
|
-
var pixi_js_1 = require("pixi.js");
|
|
24
|
-
var _Vec2 = /** @class */ (function (_super) {
|
|
25
|
-
__extends(_Vec2, _super);
|
|
26
|
-
function _Vec2() {
|
|
27
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
-
}
|
|
29
|
-
_Vec2.prototype.equals = function (other) {
|
|
30
|
-
return this.x === other.x && this.y === other.y;
|
|
31
|
-
};
|
|
32
|
-
_Vec2.prototype.addSelf = function (value) {
|
|
33
|
-
var nor = value.add(new pixi_js_1.Point(this.x, this.y));
|
|
34
|
-
this.x = nor.x;
|
|
35
|
-
this.y = nor.y;
|
|
36
|
-
return nor;
|
|
37
|
-
};
|
|
38
|
-
_Vec2.prototype.cross = function (other) {
|
|
39
|
-
return this.x * other.y - this.y * other.x;
|
|
40
|
-
};
|
|
41
|
-
_Vec2.prototype.signAngle = function (other) {
|
|
42
|
-
var angle = this.angle(other);
|
|
43
|
-
return this.cross(other) < 0 ? -angle : angle;
|
|
44
|
-
};
|
|
45
|
-
_Vec2.prototype.lengthSqr = function () {
|
|
46
|
-
return this.x * this.x + this.y * this.y;
|
|
47
|
-
};
|
|
48
|
-
_Vec2.prototype.dot = function (other) {
|
|
49
|
-
return this.x * other.x + this.y * other.y;
|
|
50
|
-
};
|
|
51
|
-
_Vec2.prototype.angle = function (other) {
|
|
52
|
-
var magSqr1 = this.lengthSqr();
|
|
53
|
-
var magSqr2 = other.lengthSqr();
|
|
54
|
-
if (magSqr1 === 0 || magSqr2 === 0) {
|
|
55
|
-
console.warn('Cant get angle between zero vector');
|
|
56
|
-
return 0.0;
|
|
57
|
-
}
|
|
58
|
-
var dot = this.dot(other);
|
|
59
|
-
var theta = dot / Math.sqrt(magSqr1 * magSqr2);
|
|
60
|
-
theta = (0, clamp_1.default)(theta, -1.0, 1.0);
|
|
61
|
-
return Math.acos(theta);
|
|
62
|
-
};
|
|
63
|
-
return _Vec2;
|
|
64
|
-
}(pixi_js_1.Point));
|
|
65
|
-
function Vec2(x, y) {
|
|
66
|
-
if (x === void 0) { x = 0; }
|
|
67
|
-
if (y === void 0) { y = 0; }
|
|
68
|
-
return new _Vec2(x, y);
|
|
69
|
-
}
|
|
70
|
-
Vec2.ZERO = Object.freeze(Vec2(0, 0));
|
package/src/app.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Application } from 'pixi.js'
|
|
2
|
-
import { actionManager } from 'pixi-action-ease'
|
|
3
|
-
|
|
4
|
-
import { GameWorld } from './gworld'
|
|
5
|
-
import { GUISystem } from './systems/GUISystem'
|
|
6
|
-
import { RenderSystem } from './systems/RenderSystem'
|
|
7
|
-
|
|
8
|
-
export const app = new Application()
|
|
9
|
-
|
|
10
|
-
export function setupResolution(designedResolution = { width: 720, height: 1280 }) {
|
|
11
|
-
const { width, height } = designedResolution
|
|
12
|
-
app.renderer.resize(width, height)
|
|
13
|
-
// app.stage.position.y = app.renderer.height / app.renderer.resolution
|
|
14
|
-
// app.stage.scale.y = -1
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function addGameCanvasTo(id = 'game') {
|
|
18
|
-
await app.init({
|
|
19
|
-
antialias: true,
|
|
20
|
-
resolution: window.devicePixelRatio,
|
|
21
|
-
eventFeatures: {
|
|
22
|
-
move: true,
|
|
23
|
-
/** disables the global move events which can be very expensive in large scenes */
|
|
24
|
-
globalMove: false,
|
|
25
|
-
click: true,
|
|
26
|
-
wheel: false,
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
// app.ticker.speed = 0.5
|
|
30
|
-
// Listen for frame updates
|
|
31
|
-
app.ticker.add(() => {
|
|
32
|
-
const dt = app.ticker.deltaMS * 0.001
|
|
33
|
-
actionManager.update(dt)
|
|
34
|
-
GameWorld.Instance.update(dt)
|
|
35
|
-
})
|
|
36
|
-
Object.assign(app.canvas.style, {
|
|
37
|
-
width: `${window.innerWidth}px`,
|
|
38
|
-
// height: `${window.innerHeight}px`,
|
|
39
|
-
overflow: 'hidden',
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const gameDiv = document.getElementById(id)
|
|
43
|
-
gameDiv.appendChild(app.canvas)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function initWorld() {
|
|
47
|
-
GameWorld.Instance.systems.add(RenderSystem)
|
|
48
|
-
GameWorld.Instance.systems.add(GUISystem)
|
|
49
|
-
GameWorld.Instance.systems.configureOnce(RenderSystem)
|
|
50
|
-
GameWorld.Instance.systems.configureOnce(GUISystem)
|
|
51
|
-
}
|