react-simple-game-engine 0.2.73 → 0.2.75
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/lib/ui-components/control-container.d.ts +8 -0
- package/lib/ui-components/control-container.d.ts.map +1 -0
- package/lib/ui-components/control-container.js +30 -0
- package/lib/ui-components/control.d.ts +5 -7
- package/lib/ui-components/control.d.ts.map +1 -1
- package/lib/ui-components/control.js +9 -39
- package/lib/ui-components/movement-control.d.ts +14 -0
- package/lib/ui-components/movement-control.d.ts.map +1 -0
- package/lib/ui-components/movement-control.js +53 -0
- package/lib/ui-components/scene-runner.d.ts +2 -2
- package/lib/ui-components/scene-runner.d.ts.map +1 -1
- package/lib/ui-components/scene-runner.js +4 -4
- package/lib/utilities.d.ts +2 -0
- package/lib/utilities.d.ts.map +1 -1
- package/lib/utilities.js +2 -0
- package/package.json +1 -1
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ReactElement } from "react";
|
2
|
+
declare type ControlContainerProps = {
|
3
|
+
full?: boolean;
|
4
|
+
children: ReactElement | ReactElement[];
|
5
|
+
};
|
6
|
+
export declare function ControlContainer({ full, children }: ControlContainerProps): JSX.Element;
|
7
|
+
export {};
|
8
|
+
//# sourceMappingURL=control-container.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"control-container.d.ts","sourceRoot":"","sources":["../../src/ui-components/control-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAE9C,aAAK,qBAAqB,GAAG;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;CACzC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,qBAAqB,eAsBzE"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { useMemo } from "react";
|
14
|
+
export function ControlContainer(_a) {
|
15
|
+
var full = _a.full, children = _a.children;
|
16
|
+
var _children = useMemo(function () {
|
17
|
+
var _children = Array.isArray(children) ? children : [children];
|
18
|
+
return _children
|
19
|
+
.reduce(function (arr, child) {
|
20
|
+
arr.push.apply(arr, (Array.isArray(child) ? child : [child]));
|
21
|
+
return arr;
|
22
|
+
}, [])
|
23
|
+
.filter(Boolean);
|
24
|
+
}, [children]);
|
25
|
+
return (_jsx("div", __assign({ style: {
|
26
|
+
width: "100%",
|
27
|
+
height: full ? "100%" : undefined,
|
28
|
+
position: "relative",
|
29
|
+
} }, { children: _children })));
|
30
|
+
}
|
@@ -1,14 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import { Scene } from "../classes/scene";
|
3
|
-
import { IJoystickProps } from "./react-joystick-component/Joystick";
|
1
|
+
import { ReactNode } from "react";
|
4
2
|
export declare type ControlProps = {
|
5
|
-
scene: Scene;
|
6
3
|
top?: number;
|
7
4
|
left?: number;
|
8
5
|
right?: number;
|
9
6
|
bottom?: number;
|
10
|
-
|
11
|
-
|
7
|
+
children: ReactNode;
|
8
|
+
xAxisOriginCenter?: false;
|
9
|
+
yAxisOriginCenter?: false;
|
12
10
|
};
|
13
|
-
export declare function Control({
|
11
|
+
export declare function Control({ xAxisOriginCenter, yAxisOriginCenter, top, left, right, bottom, children, }: ControlProps): JSX.Element;
|
14
12
|
//# sourceMappingURL=control.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,oBAAY,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,iBAAiB,CAAC,EAAE,KAAK,CAAC;IAC1B,iBAAiB,CAAC,EAAE,KAAK,CAAC;CAC3B,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACtB,iBAAyB,EACzB,iBAAyB,EACzB,GAAO,EACP,IAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,GACT,EAAE,YAAY,eAgBd"}
|
@@ -10,44 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
import { useMemo } from "react";
|
14
|
-
import { JoystickActionType } from "../export-enums";
|
15
|
-
import { Watcher } from "../utilities";
|
16
|
-
import { Joystick } from "./react-joystick-component";
|
17
13
|
export function Control(_a) {
|
18
|
-
var
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
vector: Renderer.createVector(e.x, -e.y).normalize(),
|
28
|
-
weight: e.distance / 100,
|
29
|
-
length: e.distance,
|
30
|
-
direction: e.direction,
|
31
|
-
});
|
32
|
-
}
|
33
|
-
else {
|
34
|
-
scene.emitJoystickAction({
|
35
|
-
type: e.type,
|
36
|
-
});
|
37
|
-
}
|
38
|
-
};
|
39
|
-
return (_jsx("div", __assign({ style: {
|
40
|
-
position: "absolute",
|
41
|
-
left: left,
|
42
|
-
top: top,
|
43
|
-
bottom: bottom,
|
44
|
-
right: right,
|
45
|
-
} }, { children: _jsx(Joystick, __assign({ size: 60, baseColor: "#2D2D2D", stickColor: "rgb(120,121,122)", throttle: 100 }, props, { start: onAction, move: onAction, stop: onAction })) })));
|
46
|
-
}, [props]);
|
47
|
-
return (_jsx(Watcher, __assign({ initialValues: {
|
48
|
-
isShow: defaultShow,
|
49
|
-
}, scene: scene, names: "control-visible" }, { children: function (_a) {
|
50
|
-
var isShow = _a.isShow;
|
51
|
-
return (isShow ? (render ? render(el) : el) : null);
|
52
|
-
} })));
|
14
|
+
var _b = _a.xAxisOriginCenter, xAxisOriginCenter = _b === void 0 ? false : _b, _c = _a.yAxisOriginCenter, yAxisOriginCenter = _c === void 0 ? false : _c, _d = _a.top, top = _d === void 0 ? 0 : _d, _e = _a.left, left = _e === void 0 ? 0 : _e, right = _a.right, bottom = _a.bottom, children = _a.children;
|
15
|
+
return (_jsx("div", __assign({ style: {
|
16
|
+
position: "absolute",
|
17
|
+
top: top,
|
18
|
+
left: left,
|
19
|
+
right: right,
|
20
|
+
bottom: bottom,
|
21
|
+
translate: "\n ".concat(xAxisOriginCenter ? "-50%" : 0, " ").concat(yAxisOriginCenter ? "-50%" : 0),
|
22
|
+
} }, { children: children })));
|
53
23
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
2
|
+
import { Scene } from "../classes/scene";
|
3
|
+
import { IJoystickProps } from "./react-joystick-component/Joystick";
|
4
|
+
export declare type MovementControlProps = {
|
5
|
+
scene: Scene;
|
6
|
+
top?: number;
|
7
|
+
left?: number;
|
8
|
+
right?: number;
|
9
|
+
bottom?: number;
|
10
|
+
render?: (el: ReactElement) => ReactNode;
|
11
|
+
props?: Omit<IJoystickProps, "start" | "move" | "stop">;
|
12
|
+
};
|
13
|
+
export declare function MovementControl({ scene, render, top, left, right, bottom, props, }: MovementControlProps): JSX.Element;
|
14
|
+
//# sourceMappingURL=movement-control.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"movement-control.d.ts","sourceRoot":"","sources":["../../src/ui-components/movement-control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EACL,cAAc,EAEf,MAAM,qCAAqC,CAAC;AAE7C,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;CACzD,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAS,EACT,KAAK,EACL,MAAW,EACX,KAAK,GACN,EAAE,oBAAoB,eAwDtB"}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { useMemo } from "react";
|
14
|
+
import { JoystickActionType } from "../export-enums";
|
15
|
+
import { Watcher } from "../utilities";
|
16
|
+
import { Joystick } from "./react-joystick-component";
|
17
|
+
export function MovementControl(_a) {
|
18
|
+
var scene = _a.scene, render = _a.render, top = _a.top, _b = _a.left, left = _b === void 0 ? 50 : _b, right = _a.right, _c = _a.bottom, bottom = _c === void 0 ? 50 : _c, props = _a.props;
|
19
|
+
var defaultShow = useMemo(function () {
|
20
|
+
return scene.getInitialData();
|
21
|
+
}, [scene]).joystick;
|
22
|
+
var el = useMemo(function () {
|
23
|
+
var onAction = function (e) {
|
24
|
+
if (e.type === JoystickActionType.MOVE) {
|
25
|
+
scene.emitJoystickAction({
|
26
|
+
type: e.type,
|
27
|
+
vector: Renderer.createVector(e.x, -e.y).normalize(),
|
28
|
+
weight: e.distance / 100,
|
29
|
+
length: e.distance,
|
30
|
+
direction: e.direction,
|
31
|
+
});
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
scene.emitJoystickAction({
|
35
|
+
type: e.type,
|
36
|
+
});
|
37
|
+
}
|
38
|
+
};
|
39
|
+
return (_jsx("div", __assign({ style: {
|
40
|
+
position: "absolute",
|
41
|
+
left: left,
|
42
|
+
top: top,
|
43
|
+
bottom: bottom,
|
44
|
+
right: right,
|
45
|
+
} }, { children: _jsx(Joystick, __assign({ size: 60, baseColor: "#2D2D2D", stickColor: "rgb(120,121,122)", throttle: 100 }, props, { start: onAction, move: onAction, stop: onAction })) })));
|
46
|
+
}, [props]);
|
47
|
+
return (_jsx(Watcher, __assign({ initialValues: {
|
48
|
+
isShow: defaultShow,
|
49
|
+
}, scene: scene, names: "control-visible" }, { children: function (_a) {
|
50
|
+
var isShow = _a.isShow;
|
51
|
+
return (isShow ? (render ? render(el) : el) : null);
|
52
|
+
} })));
|
53
|
+
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ComponentType, ReactNode } from "react";
|
2
2
|
import { Scene } from "../classes/scene";
|
3
3
|
import { LayoutMode } from "../export-enums";
|
4
|
-
import { ControlProps } from "./control";
|
5
4
|
import { AssetsFailBehavior } from "../export-types";
|
5
|
+
import { MovementControlProps } from "./movement-control";
|
6
6
|
export declare type SceneRunnerPublicProps = {
|
7
7
|
width: number;
|
8
8
|
height: number;
|
@@ -11,7 +11,7 @@ export declare type SceneRunnerPublicProps = {
|
|
11
11
|
assetsFailBehavior?: AssetsFailBehavior;
|
12
12
|
layoutMode?: LayoutMode;
|
13
13
|
voidSpace?: ReactNode;
|
14
|
-
joystick?: Omit<
|
14
|
+
joystick?: Omit<MovementControlProps, "scene"> | true;
|
15
15
|
};
|
16
16
|
declare type SceneRunnerProps = SceneRunnerPublicProps & {
|
17
17
|
current: Scene;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scene-runner.d.ts","sourceRoot":"","sources":["../../src/ui-components/scene-runner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"scene-runner.d.ts","sourceRoot":"","sources":["../../src/ui-components/scene-runner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,EAAmB,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG3E,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACvD,CAAC;AAEF,aAAK,gBAAgB,GAAG,sBAAsB,GAAG;IAC/C,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,OAAO,EACP,UAAiC,EAEjC,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,YAAY,EAAE,YAAY,EAC1B,QAAQ,GACT,EAAE,gBAAgB,eAsJlB"}
|
@@ -12,11 +12,11 @@ var __assign = (this && this.__assign) || function () {
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
13
13
|
import { useEffect, useMemo, useRef, useState, } from "react";
|
14
14
|
import { Scaler } from "../classes/scaler";
|
15
|
-
import { ScalerContainer } from "./scaler-container";
|
16
|
-
import { Sketch } from "./sketch";
|
17
15
|
import { useWindowSize } from "../utils";
|
18
16
|
import { LayoutMode } from "../export-enums";
|
19
|
-
import {
|
17
|
+
import { ScalerContainer } from "./scaler-container";
|
18
|
+
import { Sketch } from "./sketch";
|
19
|
+
import { MovementControl } from "./movement-control";
|
20
20
|
import { FloatContainer } from "./float-container";
|
21
21
|
export function SceneRunner(_a) {
|
22
22
|
var width = _a.width, height = _a.height, current = _a.current, _b = _a.layoutMode, layoutMode = _b === void 0 ? LayoutMode.LANDSCAPE : _b,
|
@@ -93,7 +93,7 @@ export function SceneRunner(_a) {
|
|
93
93
|
}
|
94
94
|
return rendered;
|
95
95
|
})()
|
96
|
-
: assetsLoader })) : (_jsx(_Fragment, { children: isBootDone ? (_jsxs(_Fragment, { children: [_jsx(current.UI, __assign({ scene: current }, current.getUIProps())), joystick && (_jsx(
|
96
|
+
: assetsLoader })) : (_jsx(_Fragment, { children: isBootDone ? (_jsxs(_Fragment, { children: [_jsx(current.UI, __assign({ scene: current }, current.getUIProps())), joystick && (_jsx(MovementControl, __assign({ scene: current }, (joystick === true ? {} : joystick)))), _jsx("div", { id: "scene-modal-stack", style: {
|
97
97
|
position: "absolute",
|
98
98
|
top: 0,
|
99
99
|
left: 0,
|
package/lib/utilities.d.ts
CHANGED
package/lib/utilities.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC"}
|
package/lib/utilities.js
CHANGED