react-simple-game-engine 0.3.28 → 0.3.30
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.
@@ -4,7 +4,8 @@ declare type TouchEvent = {
|
|
4
4
|
onPressed?: (container: HTMLDivElement, stick: HTMLButtonElement) => void;
|
5
5
|
onReleased?: (container: HTMLDivElement, stick: HTMLButtonElement) => void;
|
6
6
|
};
|
7
|
-
export declare type MovementControlProps =
|
7
|
+
export declare type MovementControlProps = {
|
8
|
+
onLoaded?: (container: HTMLDivElement, stick: HTMLButtonElement) => void;
|
8
9
|
top?: number;
|
9
10
|
left?: number;
|
10
11
|
right?: number;
|
@@ -14,6 +15,6 @@ export declare type MovementControlProps = TouchEvent & {
|
|
14
15
|
containerTouchEvent?: TouchEvent;
|
15
16
|
props?: Omit<IJoystickProps, "start" | "move" | "stop">;
|
16
17
|
};
|
17
|
-
export declare function MovementControl({ render, top, left, right, bottom, props, containerTouchEvent, joystickTouchEvent, }: MovementControlProps): JSX.Element;
|
18
|
+
export declare function MovementControl({ render, top, left, right, bottom, props, containerTouchEvent, joystickTouchEvent, onLoaded, }: MovementControlProps): JSX.Element;
|
18
19
|
export {};
|
19
20
|
//# sourceMappingURL=movement-control.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"movement-control.d.ts","sourceRoot":"","sources":["../../src/ui-components/movement-control.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"movement-control.d.ts","sourceRoot":"","sources":["../../src/ui-components/movement-control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAMf,OAAO,EACL,cAAc,EAEf,MAAM,qCAAqC,CAAC;AAE7C,aAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC1E,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC5E,CAAC;AACF,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACzE,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,kBAAkB,CAAC,EAAE,UAAU,CAAC;IAChC,mBAAmB,CAAC,EAAE,UAAU,CAAC;IACjC,KAAK,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;CACzD,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,GAAG,EACH,IAAS,EACT,KAAK,EACL,MAAW,EACX,KAAK,EACL,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,GACT,EAAE,oBAAoB,eAyGtB"}
|
@@ -16,7 +16,7 @@ import { UISceneContext } from "../react-context";
|
|
16
16
|
import { Watcher } from "../utilities";
|
17
17
|
import { Joystick } from "./react-joystick-component";
|
18
18
|
export function MovementControl(_a) {
|
19
|
-
var 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, containerTouchEvent = _a.containerTouchEvent, joystickTouchEvent = _a.joystickTouchEvent;
|
19
|
+
var 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, containerTouchEvent = _a.containerTouchEvent, joystickTouchEvent = _a.joystickTouchEvent, onLoaded = _a.onLoaded;
|
20
20
|
var refJoyWrap = useRef(null);
|
21
21
|
var refStick = useRef(null);
|
22
22
|
var scene = useContext(UISceneContext);
|
@@ -25,6 +25,9 @@ export function MovementControl(_a) {
|
|
25
25
|
}, [scene]).joystick;
|
26
26
|
useEffect(function () {
|
27
27
|
refStick.current = refJoyWrap.current.querySelectorAll("button")[0];
|
28
|
+
onLoaded === null || onLoaded === void 0 ? void 0 : onLoaded(refJoyWrap.current, refStick.current);
|
29
|
+
}, [onLoaded]);
|
30
|
+
useEffect(function () {
|
28
31
|
if (!joystickTouchEvent) {
|
29
32
|
return;
|
30
33
|
}
|
@@ -63,7 +66,7 @@ export function MovementControl(_a) {
|
|
63
66
|
}
|
64
67
|
};
|
65
68
|
var joystick = (_jsx(Joystick, __assign({ size: 60, baseColor: "#2D2D2D", stickColor: "rgb(120,121,122)", throttle: 100 }, props, { start: onAction, move: onAction, stop: onAction })));
|
66
|
-
return (_jsx("div", __assign({ onPointerDown: function (event) {
|
69
|
+
return (_jsx("div", __assign({ ref: refJoyWrap, onPointerDown: function (event) {
|
67
70
|
var _a;
|
68
71
|
event.target.setPointerCapture(event.pointerId);
|
69
72
|
(_a = containerTouchEvent === null || containerTouchEvent === void 0 ? void 0 : containerTouchEvent.onPressed) === null || _a === void 0 ? void 0 : _a.call(containerTouchEvent, refJoyWrap.current, refStick.current);
|
@@ -71,9 +74,7 @@ export function MovementControl(_a) {
|
|
71
74
|
var _a;
|
72
75
|
event.target.releasePointerCapture(event.pointerId);
|
73
76
|
(_a = containerTouchEvent === null || containerTouchEvent === void 0 ? void 0 : containerTouchEvent.onReleased) === null || _a === void 0 ? void 0 : _a.call(containerTouchEvent, refJoyWrap.current, refStick.current);
|
74
|
-
},
|
75
|
-
"--stick-center-x": 0,
|
76
|
-
"--stick-center-y": 0,
|
77
|
+
}, style: {
|
77
78
|
position: "absolute",
|
78
79
|
left: right != null ? undefined : left,
|
79
80
|
right: right,
|