@safe-engine/pixi 1.0.0 → 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.
Files changed (41) hide show
  1. package/README.md +4 -4
  2. package/dist/components/GUIComponent.d.ts +3 -3
  3. package/dist/components/GUIComponent.d.ts.map +1 -1
  4. package/dist/components/NodeComp.d.ts +1 -1
  5. package/dist/components/NodeComp.d.ts.map +1 -1
  6. package/dist/components/NodeComp.js +1 -1
  7. package/dist/helper/utils.d.ts +1 -7
  8. package/dist/helper/utils.d.ts.map +1 -1
  9. package/dist/helper/utils.js +5 -25
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -3
  13. package/dist/systems/GUISystem.d.ts +1 -2
  14. package/dist/systems/GUISystem.d.ts.map +1 -1
  15. package/dist/systems/GUISystem.js +52 -73
  16. package/dist/systems/RenderSystem.d.ts +1 -2
  17. package/dist/systems/RenderSystem.d.ts.map +1 -1
  18. package/dist/systems/RenderSystem.js +47 -70
  19. package/package.json +2 -3
  20. package/.github/workflows/npm-publish.yml +0 -35
  21. package/dist/core/Vec2.d.ts +0 -20
  22. package/dist/core/Vec2.d.ts.map +0 -1
  23. package/dist/core/Vec2.js +0 -70
  24. package/src/app.ts +0 -51
  25. package/src/components/EnhancedComponent.ts +0 -57
  26. package/src/components/GUIComponent.ts +0 -147
  27. package/src/components/NodeComp.ts +0 -409
  28. package/src/components/RenderComponent.ts +0 -65
  29. package/src/core/Color.ts +0 -3
  30. package/src/core/LoadingBar.ts +0 -33
  31. package/src/core/Scene.ts +0 -17
  32. package/src/core/Size.ts +0 -21
  33. package/src/core/Vec2.ts +0 -52
  34. package/src/core/decorator.ts +0 -18
  35. package/src/gworld.ts +0 -17
  36. package/src/helper/html-text-parser.ts +0 -364
  37. package/src/helper/utils.ts +0 -64
  38. package/src/index.ts +0 -10
  39. package/src/systems/GUISystem.ts +0 -95
  40. package/src/systems/RenderSystem.ts +0 -100
  41. package/tsconfig.json +0 -24
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
- }
@@ -1,57 +0,0 @@
1
- import { Constructor } from 'entityx-ts'
2
- import { actionManager, Animation, CallFunc, DelayTime, Repeat, Sequence } from 'pixi-action-ease'
3
-
4
- import { NodeComp } from './NodeComp'
5
-
6
- export class EnhancedComponent {
7
- constructor(...args: any[]) {
8
- const [data] = args
9
- if (data) {
10
- // console.log('constructor', this.constructor.name, data)
11
- Object.keys(data).forEach((key) => {
12
- this[key] = data[key]
13
- })
14
- }
15
- }
16
- node: NodeComp
17
- static hasRender = true
18
- actionsMap: { [key: string]: Animation } = {}
19
- addComponent<T extends EnhancedComponent>(instance): T {
20
- return this.node.addComponent(instance)
21
- }
22
- getComponent<T extends ComponentType>(component: Constructor<T>): T {
23
- return this.node.getComponent(component)
24
- }
25
- schedule(callback: (dt?: number) => void, interval: number, repeat = -1, delay = 0, key?: string) {
26
- const action = Sequence.create(DelayTime.create(interval), CallFunc.create(callback))
27
- const repeatAct = Repeat.create(action, repeat)
28
- const seq = Sequence.create(DelayTime.create(delay), repeatAct)
29
- const animation = actionManager.runAction(this.node.instance as any, seq)
30
- this.actionsMap[key] = animation
31
- }
32
- unschedule(callback: (arg?: unknown) => void, key?: string) {
33
- // this.node.instance.unschedule(callback.bind(this))
34
- this.actionsMap[key].stop()
35
- }
36
- unscheduleAllCallbacks() {
37
- Object.values(this.actionsMap).forEach((action: Animation) => {
38
- action.stop()
39
- })
40
- }
41
- scheduleOnce(callback: (arg?: unknown) => void, delay: number, key?: string) {
42
- const action = Sequence.create(DelayTime.create(delay), CallFunc.create(callback))
43
- const animation = actionManager.runAction(this.node.instance as any, action)
44
- this.actionsMap[key] = animation
45
- }
46
- getComponentsInChildren<T extends ComponentType>(component: Constructor<T>): T[] {
47
- return this.node.getComponentsInChildren(component)
48
- }
49
- getComponentInChildren<T extends ComponentType>(component: Constructor<T>): T {
50
- return this.node.getComponentInChildren(component)
51
- }
52
- isEqual(other: EnhancedComponent) {
53
- return this.node.entity.id === other.node.entity.id
54
- }
55
- }
56
-
57
- export type ComponentType = EnhancedComponent | NodeComp
@@ -1,147 +0,0 @@
1
- import { Assets, Text } from 'pixi.js'
2
-
3
- import { Size, Vec2 } from '..'
4
- import { Color4B } from '../core/Color'
5
- import { ComponentX, NoRenderComponentX } from '../core/decorator'
6
- import { LoadingBar, LoadingBarMode } from '../core/LoadingBar'
7
- import { HtmlTextParser } from '../helper/html-text-parser'
8
-
9
- const _htmlTextParser = new HtmlTextParser()
10
- export const FillType = {
11
- HORIZONTAL: 0,
12
- VERTICAL: 1,
13
- RADIAL: 2,
14
- }
15
- type Keys = keyof typeof FillType
16
- type Values = (typeof FillType)[Keys]
17
-
18
- export class ButtonComp extends NoRenderComponentX {
19
- normalImage: string
20
- selectedImage: string
21
- disableImage: string
22
- zoomScale: number
23
- onPress: (target: ButtonComp) => void
24
-
25
- setOnPress(cb: (target: ButtonComp) => void) {
26
- this.onPress = cb
27
- }
28
-
29
- set enabled(val) {
30
- this.node.instance.interactive = val
31
- }
32
- }
33
-
34
- export class ProgressBarComp extends NoRenderComponentX {
35
- mode = LoadingBarMode.BAR
36
- private _progress: number
37
- isReverse: boolean
38
-
39
- get progress() {
40
- return this._progress
41
- }
42
-
43
- set progress(val: number) {
44
- this._progress = val
45
- ;(this.node.instance as LoadingBar).progress = val
46
- }
47
- }
48
-
49
- export class LabelComp extends ComponentX {
50
- font: string
51
- string: string
52
- size = 64
53
-
54
- getString() {
55
- if (this.node.instance instanceof Text) {
56
- return this.node.instance.text
57
- }
58
- }
59
-
60
- setString(val: string) {
61
- if (this.node.instance instanceof Text) {
62
- this.node.instance.text = val
63
- }
64
- }
65
-
66
- getSize() {
67
- if (this.node.instance instanceof Text) {
68
- return this.node.instance.style.fontSize
69
- }
70
- }
71
- setSize(val) {
72
- if (this.node.instance instanceof Text) {
73
- this.node.instance.style.fontSize = val
74
- }
75
- }
76
-
77
- getFont() {
78
- if (this.node.instance instanceof Text) {
79
- return this.node.instance.style.fontFamily as string
80
- }
81
- }
82
-
83
- setFont(val: string) {
84
- // console.log('set font', val, Assets.get(val))
85
- if (this.node.instance instanceof Text) {
86
- if (Assets.get(val)) this.node.instance.style.fontFamily = Assets.get(val).family
87
- }
88
- }
89
- }
90
-
91
- export class ScrollView extends ComponentX {
92
- width: number
93
- height: number
94
- }
95
-
96
- export class BlockInputEventsComp extends NoRenderComponentX {}
97
-
98
- export class ProgressTimerComp extends ComponentX {
99
- spriteFrame: string
100
- fillType: Values
101
- fillRange: number
102
- fillCenter: Vec2
103
- isReverse: boolean
104
-
105
- getFillRange() {
106
- // if (this.node.instance instanceof cc.ProgressTimer) {
107
- // return this.node.instance.getPercentage() * 0.01
108
- // }
109
- }
110
-
111
- setFillStart(val: number) {
112
- // if (this.node.instance instanceof cc.ProgressTimer) {
113
- // this.node.instance.setMidpoint(Vec2(val, val))
114
- // }
115
- }
116
-
117
- setFillRange(val: number) {
118
- // if (this.node.instance instanceof cc.ProgressTimer) {
119
- // this.node.instance.setPercentage(val * 100)
120
- // }
121
- }
122
- }
123
-
124
- export class RichTextComp extends ComponentX {
125
- protected font: string
126
- protected string: string
127
- protected size: number
128
-
129
- getString() {
130
- return this.string
131
- }
132
-
133
- setString(val: string) {
134
- this.string = val
135
- }
136
- }
137
-
138
- export class LabelOutlineComp extends NoRenderComponentX {
139
- color: typeof Color4B
140
- width: number
141
- }
142
-
143
- export class LabelShadowComp extends NoRenderComponentX {
144
- color: typeof Color4B
145
- blur: number
146
- offset: Size
147
- }