@rpgjs/client 5.0.0-alpha.23 → 5.0.0-alpha.24

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 (79) hide show
  1. package/dist/RpgClientEngine.d.ts +35 -115
  2. package/dist/components/gui/mobile/index.d.ts +1 -1
  3. package/dist/index10.js +1 -1
  4. package/dist/index11.js +2 -2
  5. package/dist/index12.js +2 -2
  6. package/dist/index14.js +1 -2
  7. package/dist/index14.js.map +1 -1
  8. package/dist/index15.js +4 -4
  9. package/dist/index16.js.map +1 -1
  10. package/dist/index17.js.map +1 -1
  11. package/dist/index2.js +85 -159
  12. package/dist/index2.js.map +1 -1
  13. package/dist/index20.js.map +1 -1
  14. package/dist/index22.js +1 -1
  15. package/dist/index25.js +2 -2
  16. package/dist/index25.js.map +1 -1
  17. package/dist/index26.js +2 -3
  18. package/dist/index26.js.map +1 -1
  19. package/dist/index28.js +2 -2
  20. package/dist/index28.js.map +1 -1
  21. package/dist/index3.js +1 -1
  22. package/dist/index31.js +2622 -42
  23. package/dist/index31.js.map +1 -1
  24. package/dist/index32.js +88 -2607
  25. package/dist/index32.js.map +1 -1
  26. package/dist/index33.js +64 -107
  27. package/dist/index33.js.map +1 -1
  28. package/dist/index34.js +12 -62
  29. package/dist/index34.js.map +1 -1
  30. package/dist/index35.js +24 -18
  31. package/dist/index35.js.map +1 -1
  32. package/dist/index36.js +87 -19
  33. package/dist/index36.js.map +1 -1
  34. package/dist/index37.js +20 -74
  35. package/dist/index37.js.map +1 -1
  36. package/dist/index38.js +18 -35
  37. package/dist/index38.js.map +1 -1
  38. package/dist/index39.js +137 -20
  39. package/dist/index39.js.map +1 -1
  40. package/dist/index4.js +1 -1
  41. package/dist/index40.js +9 -133
  42. package/dist/index40.js.map +1 -1
  43. package/dist/index41.js +3 -41
  44. package/dist/index41.js.map +1 -1
  45. package/dist/index42.js +536 -1
  46. package/dist/index42.js.map +1 -1
  47. package/dist/index43.js +30 -183
  48. package/dist/index43.js.map +1 -1
  49. package/dist/index44.js +9 -501
  50. package/dist/index44.js.map +1 -1
  51. package/dist/index45.js +6 -334
  52. package/dist/index45.js.map +1 -1
  53. package/dist/index46.js +325 -30
  54. package/dist/index46.js.map +1 -1
  55. package/dist/index47.js +3680 -67
  56. package/dist/index47.js.map +1 -1
  57. package/dist/index48.js +75 -10
  58. package/dist/index48.js.map +1 -1
  59. package/dist/index49.js +186 -6
  60. package/dist/index49.js.map +1 -1
  61. package/dist/index50.js +499 -3685
  62. package/dist/index50.js.map +1 -1
  63. package/dist/index53.js +1 -1
  64. package/dist/index8.js +6 -1
  65. package/dist/index8.js.map +1 -1
  66. package/dist/index9.js +1 -2
  67. package/dist/index9.js.map +1 -1
  68. package/package.json +9 -9
  69. package/src/Gui/Gui.ts +0 -1
  70. package/src/RpgClientEngine.ts +106 -176
  71. package/src/components/character.ce +2 -3
  72. package/src/components/gui/mobile/index.ts +1 -1
  73. package/src/components/gui/mobile/mobile.ce +73 -88
  74. package/src/components/prebuilt/light-halo.ce +2 -71
  75. package/src/components/scenes/canvas.ce +0 -10
  76. package/src/components/scenes/event-layer.ce +1 -0
  77. package/src/module.ts +6 -1
  78. package/dist/Game/TransitionManager.d.ts +0 -56
  79. package/src/Game/TransitionManager.ts +0 -75
@@ -1,95 +1,80 @@
1
1
  <Container justifyContent="space-between" alignItems="flex-end" width="100%" height="100%">
2
- <Container justifyContent="flex-start" alignItems="flex-end" margin={100} gap={20}>
3
- <Button
4
- text="A"
5
- width={60}
6
- height={60}
7
- style={{
8
- backgroundColor: {
9
- normal: '#4CAF50',
10
- hover: '#45a049',
11
- pressed: '#3d8b40'
12
- },
13
- border: {
14
- color: '#2e7d32',
15
- width: 3,
16
- radius: 30
17
- },
18
- text: {
19
- color: '#ffffff',
20
- fontSize: 24,
21
- fontFamily: 'Arial'
22
- }
23
- }}
24
- click={onButtonAClick}
25
- />
26
- <Button
27
- text="B"
28
- width={60}
29
- height={60}
30
- style={{
31
- backgroundColor: {
32
- normal: '#f44336',
33
- hover: '#da190b',
34
- pressed: '#c62828'
35
- },
36
- border: {
37
- color: '#b71c1c',
38
- width: 3,
39
- radius: 30
40
- },
41
- text: {
42
- color: '#ffffff',
43
- fontSize: 24,
44
- fontFamily: 'Arial'
45
- }
46
- }}
47
- click={onButtonBClick}
48
- />
2
+ <!-- Gamepad buttons A and B (left side) -->
3
+ <Container justifyContent="flex-start" alignItems="flex-end" gap={20}>
4
+ <Container display="flex" direction="column" gap={20} margin={50}>
5
+ <!-- Button B (top) -->
6
+
7
+ <!-- Button A (bottom) -->
8
+ <Button
9
+ text="A"
10
+ shape="circle"
11
+ width={70}
12
+ height={70}
13
+ controls={controlsInstance}
14
+ controlName="action"
15
+ style={{
16
+ backgroundColor: {
17
+ normal: "#2ecc71",
18
+ hover: "#27ae60",
19
+ pressed: "#229954",
20
+ disabled: "#7f8c8d"
21
+ },
22
+ text: {
23
+ fontSize: 24,
24
+ fontFamily: "Arial Bold",
25
+ color: "#ffffff"
26
+ }
27
+ }}
28
+ />
29
+
30
+ <Button
31
+ text="B"
32
+ shape="circle"
33
+ width={70}
34
+ height={70}
35
+ controls={controlsInstance}
36
+ controlName="back"
37
+ style={{
38
+ backgroundColor: {
39
+ normal: "#e74c3c",
40
+ hover: "#c0392b",
41
+ pressed: "#a93226",
42
+ disabled: "#7f8c8d"
43
+ },
44
+ text: {
45
+ fontSize: 24,
46
+ fontFamily: "Arial Bold",
47
+ color: "#ffffff"
48
+ }
49
+ }}
50
+ />
51
+
52
+ </Container>
49
53
  </Container>
50
- <Container margin={100}>
51
- <Joystick onChange onEnd />
54
+
55
+ <Container margin={100} alignItems="flex-end">
56
+ <Container>
57
+ <Joystick
58
+ controls={controlsInstance}
59
+ outerColor="#34495e"
60
+ innerColor="#3498db"
61
+ />
62
+ </Container>
52
63
  </Container>
53
- </Container>
54
-
55
- <script>
56
- import { effect } from 'canvasengine'
57
- import { Joystick } from '@canvasengine/presets'
58
- import { Button } from 'canvasengine'
59
- import { inject } from '../../../core/inject'
60
- import { RpgClientEngine } from '../../../RpgClientEngine'
64
+ </Container>
61
65
 
62
- let lastDirection = null
63
- const client = inject(RpgClientEngine)
66
+ <script>
67
+ import { signal, mount } from 'canvasengine'
68
+ import { Button } from 'canvasengine'
69
+ import { inject } from '../../../core/inject'
70
+ import { RpgClientEngine } from '../../../RpgClientEngine'
71
+ import { Direction } from '@rpgjs/common'
64
72
 
65
- const onChange = (event) => {
66
- const control = inject('KeyboardControls')
67
- if (lastDirection !== event.direction) {
68
- if (lastDirection !== null) {
69
- control.applyControl(lastDirection, true)
70
- }
71
- lastDirection = event.direction
72
- control.applyControl(lastDirection)
73
- }
74
- }
75
-
76
- const onEnd = () => {
77
- const control = inject('KeyboardControls')
78
- if (lastDirection !== null) {
79
- control.applyControl(lastDirection, false)
80
- lastDirection = null
81
- }
82
- }
83
73
 
84
- const onButtonAClick = () => {
85
- if (client) {
86
- client.processAction({ action: 'action' })
87
- }
88
- }
74
+ const controlsInstance = signal(null)
89
75
 
90
- const onButtonBClick = () => {
91
- if (client) {
92
- client.processAction({ action: 'back' })
93
- }
94
- }
95
- </script>
76
+ mount((element) => {
77
+ const control = inject('KeyboardControls')
78
+ controlsInstance.set(control)
79
+ })
80
+ </script>
@@ -1,71 +1,5 @@
1
- <!--
2
- Light Halo Component
3
-
4
- A beautiful animated light halo effect that pulses and moves around sprites.
5
- Creates a glowing light effect with smooth animations for size and opacity.
6
-
7
- ## Design
8
-
9
- The halo uses a radial gradient to create a soft light effect that:
10
- - Pulses in size (breathing effect)
11
- - Fades in and out (opacity animation)
12
- - Can be positioned relative to the sprite
13
- - Uses blur and alpha for realistic light diffusion
14
-
15
- ## Props
16
-
17
- All props are optional and have sensible defaults:
18
- - `baseRadius` (number, default: 30) - Base radius in pixels
19
- - `radiusVariation` (number, default: 10) - Pulse variation range
20
- - `baseOpacity` (number, default: 0.6) - Base opacity (0-1)
21
- - `opacityVariation` (number, default: 0.3) - Opacity fade range
22
- - `sizeSpeed` (number, default: 0.002) - Size animation speed
23
- - `opacitySpeed` (number, default: 0.003) - Opacity animation speed
24
- - `lightColor` (number, default: 0xffffaa) - Light color (hex)
25
-
26
- @example
27
- ```ts
28
- import LightHalo from './light-halo.ce';
29
-
30
- // Basic usage with defaults
31
- export default defineModule<RpgClient>({
32
- sprite: {
33
- componentsBehind: [LightHalo]
34
- }
35
- })
36
-
37
- // Custom configuration
38
- export default defineModule<RpgClient>({
39
- sprite: {
40
- componentsBehind: [{
41
- component: LightHalo,
42
- props: {
43
- baseRadius: 50,
44
- radiusVariation: 15,
45
- lightColor: 0xffaaaa,
46
- baseOpacity: 0.8
47
- }
48
- }]
49
- }
50
- })
51
-
52
- // Dynamic props based on sprite state
53
- export default defineModule<RpgClient>({
54
- sprite: {
55
- componentsBehind: [{
56
- component: LightHalo,
57
- props: (object: RpgClientObject) => ({
58
- baseRadius: 30 + (object.param.level() * 2),
59
- lightColor: object.param.level() > 10 ? 0xffaa00 : 0xffffaa
60
- })
61
- }]
62
- }
63
- })
64
- ```
65
- -->
66
-
67
1
  <Container x={position.@x} y={position.@y}>
68
- <Graphics draw={drawHalo} />
2
+ <Graphics draw={drawHalo} />
69
3
  </Container>
70
4
 
71
5
  <script>
@@ -181,9 +115,7 @@ const drawHalo = (g) => {
181
115
  const color = getLightColor();
182
116
 
183
117
  if (opacity <= 0 || radius <= 0) return;
184
-
185
- g.clear();
186
-
118
+
187
119
  // Set blend mode to ADD for glowing light effect
188
120
  g.blendMode = 'add';
189
121
 
@@ -209,7 +141,6 @@ const drawHalo = (g) => {
209
141
  // ====================
210
142
  // Animation loop
211
143
  // ====================
212
-
213
144
  tick(() => {
214
145
  time.update(t => t + 1);
215
146
  });
@@ -15,15 +15,6 @@
15
15
  }
16
16
  </Container>
17
17
  }
18
- <Container positionType="absolute" top={0} left={0} right={0} bottom={0}>
19
- @for (transition of transitions) {
20
- <Container>
21
- @for (activeTransition of transition.current) {
22
- <transition.component ...activeTransition />
23
- }
24
- </Container>
25
- }
26
- </Container>
27
18
  </Canvas>
28
19
 
29
20
  <script>
@@ -39,7 +30,6 @@
39
30
  const gui = computed(() => {
40
31
  return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite)
41
32
  })
42
- const transitions = engine.transitions
43
33
  const worldWidth = computed(() => sceneData()?.width)
44
34
  const worldHeight = computed(() => sceneData()?.height)
45
35
 
@@ -17,6 +17,7 @@
17
17
  import { inject } from "../../core/inject";
18
18
  import { RpgClientEngine } from "../../RpgClientEngine";
19
19
  import Character from "../character.ce";
20
+ import LightHalo from "../prebuilt/light-halo.ce";
20
21
 
21
22
  const engine = inject(RpgClientEngine);
22
23
  const { children } = defineProps()
package/src/module.ts CHANGED
@@ -159,8 +159,13 @@ export function provideClientModules(modules: RpgClientModule[]): FactoryProvide
159
159
  const transitions = [...module.transitions];
160
160
  module.transitions = {
161
161
  load: (engine: RpgClientEngine) => {
162
+ const guiService = inject(engine.context, RpgGui) as RpgGui;
162
163
  transitions.forEach((transition) => {
163
- engine.addTransition(transition);
164
+ guiService.add({
165
+ name: transition.id,
166
+ component: transition.component,
167
+ data: transition.props || {}
168
+ });
164
169
  });
165
170
  },
166
171
  };
@@ -1,56 +0,0 @@
1
- /**
2
- * Manages active transitions in the game
3
- *
4
- * This class handles the lifecycle of screen transitions, such as fade effects,
5
- * slide transitions, or any custom transition components. It maintains a list
6
- * of currently active transitions and provides methods to start and finish them.
7
- *
8
- * ## Design
9
- *
10
- * - Uses signals to track active transitions reactively
11
- * - Each transition has a unique ID for identification
12
- * - Transitions automatically remove themselves when finished via onFinish callback
13
- * - Supports multiple simultaneous transitions if needed
14
- *
15
- * @example
16
- * ```ts
17
- * const manager = new TransitionManager();
18
- *
19
- * // Start a fade transition
20
- * manager.start('fade', { duration: 1000 });
21
- *
22
- * // Check active transitions
23
- * console.log(manager.current()); // Array of active transitions
24
- * ```
25
- */
26
- export declare class TransitionManager {
27
- /**
28
- * Signal containing all currently active transitions
29
- *
30
- * Each transition object contains:
31
- * - id: Unique identifier
32
- * - props: Properties passed to the transition component
33
- * - onFinish: Callback to remove the transition when complete
34
- */
35
- current: import('canvasengine').WritableArraySignal<any[]>;
36
- /**
37
- * Start a new transition
38
- *
39
- * Creates a new transition instance with the given props and adds it to
40
- * the active transitions list. The transition will be automatically removed
41
- * when it calls its onFinish callback.
42
- *
43
- * @param props - Properties to pass to the transition component (must include onFinish)
44
- * @returns The created transition object with id and onFinish callback
45
- *
46
- * @example
47
- * ```ts
48
- * const transition = manager.start({
49
- * duration: 1000,
50
- * color: 'black',
51
- * onFinish: () => console.log('Transition complete')
52
- * });
53
- * ```
54
- */
55
- start(props: any): any;
56
- }
@@ -1,75 +0,0 @@
1
- import { generateUID } from "@rpgjs/common";
2
- import { signal } from "canvasengine";
3
-
4
- /**
5
- * Manages active transitions in the game
6
- *
7
- * This class handles the lifecycle of screen transitions, such as fade effects,
8
- * slide transitions, or any custom transition components. It maintains a list
9
- * of currently active transitions and provides methods to start and finish them.
10
- *
11
- * ## Design
12
- *
13
- * - Uses signals to track active transitions reactively
14
- * - Each transition has a unique ID for identification
15
- * - Transitions automatically remove themselves when finished via onFinish callback
16
- * - Supports multiple simultaneous transitions if needed
17
- *
18
- * @example
19
- * ```ts
20
- * const manager = new TransitionManager();
21
- *
22
- * // Start a fade transition
23
- * manager.start('fade', { duration: 1000 });
24
- *
25
- * // Check active transitions
26
- * console.log(manager.current()); // Array of active transitions
27
- * ```
28
- */
29
- export class TransitionManager {
30
- /**
31
- * Signal containing all currently active transitions
32
- *
33
- * Each transition object contains:
34
- * - id: Unique identifier
35
- * - props: Properties passed to the transition component
36
- * - onFinish: Callback to remove the transition when complete
37
- */
38
- current = signal<any[]>([]);
39
-
40
- /**
41
- * Start a new transition
42
- *
43
- * Creates a new transition instance with the given props and adds it to
44
- * the active transitions list. The transition will be automatically removed
45
- * when it calls its onFinish callback.
46
- *
47
- * @param props - Properties to pass to the transition component (must include onFinish)
48
- * @returns The created transition object with id and onFinish callback
49
- *
50
- * @example
51
- * ```ts
52
- * const transition = manager.start({
53
- * duration: 1000,
54
- * color: 'black',
55
- * onFinish: () => console.log('Transition complete')
56
- * });
57
- * ```
58
- */
59
- start(props: any) {
60
- const id = generateUID();
61
- const transition = {
62
- ...props,
63
- id,
64
- onFinish: () => {
65
- const index = this.current().findIndex((value) => value.id === id);
66
- if (index !== -1) {
67
- this.current().splice(index, 1);
68
- }
69
- },
70
- };
71
-
72
- this.current().push(transition);
73
- return transition;
74
- }
75
- }