canvasengine 2.0.0-beta.34 → 2.0.0-beta.36
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/dist/{DebugRenderer-BYa_lwD-.js → DebugRenderer-DDfZuvTR.js} +2 -2
- package/dist/{DebugRenderer-BYa_lwD-.js.map → DebugRenderer-DDfZuvTR.js.map} +1 -1
- package/dist/components/Container.d.ts +4 -0
- package/dist/components/Container.d.ts.map +1 -1
- package/dist/components/DOMContainer.d.ts +4 -0
- package/dist/components/DOMContainer.d.ts.map +1 -1
- package/dist/components/DisplayObject.d.ts +4 -0
- package/dist/components/DisplayObject.d.ts.map +1 -1
- package/dist/components/Mesh.d.ts +4 -0
- package/dist/components/Mesh.d.ts.map +1 -1
- package/dist/components/Sprite.d.ts +48 -0
- package/dist/components/Sprite.d.ts.map +1 -1
- package/dist/components/Viewport.d.ts +4 -0
- package/dist/components/Viewport.d.ts.map +1 -1
- package/dist/components/types/DisplayObject.d.ts +4 -0
- package/dist/components/types/DisplayObject.d.ts.map +1 -1
- package/dist/directives/Controls.d.ts +102 -0
- package/dist/directives/Controls.d.ts.map +1 -0
- package/dist/directives/ControlsBase.d.ts +198 -0
- package/dist/directives/ControlsBase.d.ts.map +1 -0
- package/dist/directives/Flash.d.ts +117 -0
- package/dist/directives/Flash.d.ts.map +1 -0
- package/dist/directives/GamepadControls.d.ts +223 -0
- package/dist/directives/GamepadControls.d.ts.map +1 -0
- package/dist/directives/KeyboardControls.d.ts +55 -366
- package/dist/directives/KeyboardControls.d.ts.map +1 -1
- package/dist/directives/Shake.d.ts +98 -0
- package/dist/directives/Shake.d.ts.map +1 -0
- package/dist/directives/index.d.ts +11 -1
- package/dist/directives/index.d.ts.map +1 -1
- package/dist/engine/trigger.d.ts +2 -3
- package/dist/engine/trigger.d.ts.map +1 -1
- package/dist/engine/utils.d.ts.map +1 -1
- package/dist/{index-BLbc2zG5.js → index--faZajmD.js} +4547 -3970
- package/dist/index--faZajmD.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +6 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +70 -57
- package/package.json +2 -1
- package/src/components/Container.ts +17 -0
- package/src/components/DisplayObject.ts +45 -6
- package/src/components/Sprite.ts +87 -3
- package/src/components/types/DisplayObject.ts +4 -0
- package/src/directives/Controls.ts +182 -0
- package/src/directives/ControlsBase.ts +266 -0
- package/src/directives/Flash.ts +409 -0
- package/src/directives/GamepadControls.ts +515 -0
- package/src/directives/KeyboardControls.ts +66 -426
- package/src/directives/Shake.ts +282 -0
- package/src/directives/index.ts +11 -6
- package/src/engine/trigger.ts +2 -2
- package/src/engine/utils.ts +4 -0
- package/src/index.ts +1 -1
- package/dist/index-BLbc2zG5.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Element } from '../engine/reactive';
|
|
1
|
+
import { ControlsBase, ControlOptions, Controls, BoundKey } from './ControlsBase';
|
|
3
2
|
|
|
4
3
|
export declare enum Input {
|
|
5
4
|
Break = "break",
|
|
@@ -142,42 +141,49 @@ export declare enum Input {
|
|
|
142
141
|
BackQuote = "`",
|
|
143
142
|
Altgr = "altgr"
|
|
144
143
|
}
|
|
145
|
-
export
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
144
|
+
export type { ControlOptions, Controls, BoundKey };
|
|
145
|
+
/**
|
|
146
|
+
* Keyboard input controls implementation
|
|
147
|
+
*
|
|
148
|
+
* Handles keyboard input events and maps them to control actions.
|
|
149
|
+
* Supports composite directions (diagonal movement) and key repeat functionality.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* const keyboardControls = new KeyboardControls();
|
|
154
|
+
* keyboardControls.setInputs({
|
|
155
|
+
* up: {
|
|
156
|
+
* repeat: true,
|
|
157
|
+
* bind: Input.Up,
|
|
158
|
+
* keyDown() {
|
|
159
|
+
* console.log('Up pressed');
|
|
160
|
+
* }
|
|
161
|
+
* }
|
|
162
|
+
* });
|
|
163
|
+
* keyboardControls.start();
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export declare class KeyboardControls extends ControlsBase {
|
|
164
167
|
private keyState;
|
|
165
|
-
private boundKeys;
|
|
166
|
-
private stop;
|
|
167
168
|
private lastKeyPressed;
|
|
168
|
-
private _controlsOptions;
|
|
169
|
-
private interval;
|
|
170
|
-
private serverFps;
|
|
171
169
|
private directionState;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Setup keyboard event listeners
|
|
172
|
+
*/
|
|
173
|
+
protected setupListeners(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Cleanup keyboard event listeners
|
|
176
|
+
*/
|
|
177
|
+
protected cleanup(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Process keyboard inputs each step
|
|
180
|
+
*/
|
|
181
|
+
protected preStep(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Apply input for a keyboard key
|
|
184
|
+
* Overrides base implementation to handle key state and repeat logic
|
|
185
|
+
*/
|
|
186
|
+
protected applyInput(keyName: string): void;
|
|
181
187
|
private applyKeyDown;
|
|
182
188
|
private applyKeyUp;
|
|
183
189
|
private applyKeyPress;
|
|
@@ -185,346 +191,29 @@ export declare class KeyboardControls extends Directive {
|
|
|
185
191
|
private updateDirectionState;
|
|
186
192
|
private getDirection;
|
|
187
193
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* ```ts
|
|
191
|
-
* import { Input, inject, KeyboardControls } from '@rpgjs/client'
|
|
192
|
-
*
|
|
193
|
-
* const controls = inject(KeyboardControls)
|
|
194
|
-
* controls.getControl(Input.Enter)
|
|
195
|
-
|
|
196
|
-
* if (control) {
|
|
197
|
-
* console.log(control.actionName) // action
|
|
198
|
-
* }
|
|
199
|
-
* ```
|
|
200
|
-
* @title Get Control
|
|
201
|
-
* @method getControl(inputName)
|
|
202
|
-
* @param {string} inputName
|
|
203
|
-
* @returns { { actionName: string, options: any } | undefined }
|
|
204
|
-
* @memberof KeyboardControls
|
|
205
|
-
*/
|
|
206
|
-
getControl(inputName: string): BoundKey | undefined;
|
|
207
|
-
/**
|
|
208
|
-
* Returns all controls
|
|
209
|
-
*
|
|
210
|
-
* @method getControls()
|
|
211
|
-
* @since 4.2.0
|
|
212
|
-
* @returns { { [key: string]: BoundKey } }
|
|
213
|
-
* @memberof KeyboardControls
|
|
214
|
-
*/
|
|
215
|
-
getControls(): {
|
|
216
|
-
[key: string]: BoundKey;
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* Triggers an input according to the name of the control
|
|
194
|
+
* Apply a control action programmatically
|
|
195
|
+
* Triggers keyboard events to simulate key presses
|
|
220
196
|
*
|
|
197
|
+
* @param controlName - Name of the control
|
|
198
|
+
* @param isDown - Whether the key is pressed (true) or released (false)
|
|
199
|
+
* @returns Promise that resolves when the action is complete
|
|
200
|
+
* @example
|
|
221
201
|
* ```ts
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* const controls = inject(KeyboardControls)
|
|
225
|
-
* controls.applyControl(Control.Action)
|
|
226
|
-
* ```
|
|
227
|
-
*
|
|
228
|
-
* You can put a second parameter or indicate on whether the key is pressed or released
|
|
202
|
+
* // Press a key
|
|
203
|
+
* await keyboardControls.applyControl('action', true);
|
|
229
204
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
205
|
+
* // Release a key
|
|
206
|
+
* await keyboardControls.applyControl('action', false);
|
|
232
207
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* controls.applyControl(Control.Up, false) // keyup
|
|
208
|
+
* // Press and release (default)
|
|
209
|
+
* await keyboardControls.applyControl('action');
|
|
236
210
|
* ```
|
|
237
|
-
* @title Apply Control
|
|
238
|
-
* @method applyControl(controlName,isDown)
|
|
239
|
-
* @param {string} controlName
|
|
240
|
-
* @param {boolean} [isDown]
|
|
241
|
-
* @returns {Promise<void>}
|
|
242
|
-
* @memberof KeyboardControls
|
|
243
211
|
*/
|
|
244
212
|
applyControl(controlName: string | number, isDown?: boolean | undefined): Promise<void>;
|
|
245
213
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* @title Stop Inputs
|
|
249
|
-
* @method stopInputs()
|
|
250
|
-
* @returns {void}
|
|
251
|
-
* @memberof KeyboardControls
|
|
252
|
-
*/
|
|
253
|
-
stopInputs(): void;
|
|
254
|
-
/**
|
|
255
|
-
* Listen to the inputs again
|
|
256
|
-
*
|
|
257
|
-
* @title Listen Inputs
|
|
258
|
-
* @method listenInputs()
|
|
259
|
-
* @returns {void}
|
|
260
|
-
* @memberof KeyboardControls
|
|
214
|
+
* Resume listening to inputs after stopInputs() was called
|
|
215
|
+
* Also resets keyboard state
|
|
261
216
|
*/
|
|
262
217
|
listenInputs(): void;
|
|
263
|
-
/**
|
|
264
|
-
* Assign custom inputs to the scene
|
|
265
|
-
*
|
|
266
|
-
* The object is the following:
|
|
267
|
-
*
|
|
268
|
-
* * the key of the object is the name of the control. Either it is existing controls (Up, Dow, Left, Right, Action, Back) or customized controls
|
|
269
|
-
* * The value is an object representing control information:
|
|
270
|
-
* * repeat {boolean} The key can be held down to repeat the action. (false by default)
|
|
271
|
-
* * bind {string | string[]} To which key is linked the control
|
|
272
|
-
* * method {Function} Function to be triggered. If you do not set this property, the name of the control is sent directly to the server.
|
|
273
|
-
* * delay {object|number} (since v3.2.0) Indicates how long (in milliseconds) the player can press the key again to perform the action
|
|
274
|
-
* * delay.duration
|
|
275
|
-
* * delay.otherControls {string | string[]} Indicates the other controls that will also have the delay at the same time
|
|
276
|
-
*
|
|
277
|
-
* ```ts
|
|
278
|
-
* import { Control, Input, inject, KeyboardControls } from '@rpgjs/client'
|
|
279
|
-
*
|
|
280
|
-
* const controls = inject(KeyboardControls)
|
|
281
|
-
* controls.setInputs({
|
|
282
|
-
[Control.Up]: {
|
|
283
|
-
repeat: true,
|
|
284
|
-
bind: Input.Up
|
|
285
|
-
},
|
|
286
|
-
[Control.Down]: {
|
|
287
|
-
repeat: true,
|
|
288
|
-
bind: Input.Down
|
|
289
|
-
},
|
|
290
|
-
[Control.Right]: {
|
|
291
|
-
repeat: true,
|
|
292
|
-
bind: Input.Right
|
|
293
|
-
},
|
|
294
|
-
[Control.Left]: {
|
|
295
|
-
repeat: true,
|
|
296
|
-
bind: Input.Left
|
|
297
|
-
},
|
|
298
|
-
[Control.Action]: {
|
|
299
|
-
bind: [Input.Space, Input.Enter]
|
|
300
|
-
},
|
|
301
|
-
[Control.Back]: {
|
|
302
|
-
bind: Input.Escape
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
// The myscustom1 control is sent to the server when the A key is pressed.
|
|
306
|
-
mycustom1: {
|
|
307
|
-
bind: Input.A
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
// the myAction method is executed when the B key is pressed
|
|
311
|
-
mycustom2: {
|
|
312
|
-
bind: Input.B,
|
|
313
|
-
method({ actionName }) {
|
|
314
|
-
console.log('cool', actionName)
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
|
|
318
|
-
// The player can redo the action after 400ms
|
|
319
|
-
mycustom3: {
|
|
320
|
-
bind: Input.C,
|
|
321
|
-
delay: 400 // ms
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
// The player can redo the action (mycustom4) and the directions after 400ms
|
|
325
|
-
mycustom4: {
|
|
326
|
-
bind: Input.C,
|
|
327
|
-
delay: {
|
|
328
|
-
duration: 400,
|
|
329
|
-
otherControls: [Control.Up, Control.Down, Control.Left, Control.Right]
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
*
|
|
334
|
-
* ```
|
|
335
|
-
* @enum {string} Control
|
|
336
|
-
*
|
|
337
|
-
* Control.Up | up
|
|
338
|
-
* Control.Down | down
|
|
339
|
-
* Control.Left | left
|
|
340
|
-
* Control.Right | right
|
|
341
|
-
* Control.Action | action
|
|
342
|
-
* Control.Back | back
|
|
343
|
-
*
|
|
344
|
-
* @enum {string} Mouse Event
|
|
345
|
-
*
|
|
346
|
-
* click | Click
|
|
347
|
-
* dblclick | Double Click
|
|
348
|
-
* mousedown | Mouse Down
|
|
349
|
-
* mouseup | Mouse Up
|
|
350
|
-
* mouseover | Mouse Over
|
|
351
|
-
* mousemove | Mouse Move
|
|
352
|
-
* mouseout | Mouse Out
|
|
353
|
-
* contextmenu | Context Menu
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* @enum {string} Input
|
|
357
|
-
*
|
|
358
|
-
* break | Pause
|
|
359
|
-
* backspace | Backspace / Delete
|
|
360
|
-
* tab | Tab
|
|
361
|
-
* clear | Clear
|
|
362
|
-
* enter | Enter
|
|
363
|
-
* shift | Shift
|
|
364
|
-
* ctrl | Control
|
|
365
|
-
* alt | Alt
|
|
366
|
-
* pause/break | Pause / Break
|
|
367
|
-
* caps lock | Caps Lock
|
|
368
|
-
* escape | Escape
|
|
369
|
-
* conversion | Conversion
|
|
370
|
-
* non-conversion | Non-conversion
|
|
371
|
-
* space | Space
|
|
372
|
-
* page up | Page Up
|
|
373
|
-
* page down | Page Down
|
|
374
|
-
* end | End
|
|
375
|
-
* home | Home
|
|
376
|
-
* left | Left Arrow
|
|
377
|
-
* up | Up Arrow
|
|
378
|
-
* right | Right Arrow
|
|
379
|
-
* down | Down Arrow
|
|
380
|
-
* select | Select
|
|
381
|
-
* print | Print
|
|
382
|
-
* execute | Execute
|
|
383
|
-
* Print Screen | Print Screen
|
|
384
|
-
* insert | Insert
|
|
385
|
-
* delete | Delete
|
|
386
|
-
* n0 | 0
|
|
387
|
-
* n1 | 1
|
|
388
|
-
* n2 | 2
|
|
389
|
-
* n3 | 3
|
|
390
|
-
* n4 | 4
|
|
391
|
-
* n5 | 5
|
|
392
|
-
* n6 | 6
|
|
393
|
-
* n7 | 7
|
|
394
|
-
* n8 | 8
|
|
395
|
-
* n9 | 9
|
|
396
|
-
* : | Colon
|
|
397
|
-
* semicolon (firefox), equals | Semicolon (Firefox), Equals
|
|
398
|
-
* < | Less Than
|
|
399
|
-
* equals (firefox) | Equals (Firefox)
|
|
400
|
-
* ß | Eszett
|
|
401
|
-
* @ | At
|
|
402
|
-
* a | A
|
|
403
|
-
* b | B
|
|
404
|
-
* c | C
|
|
405
|
-
* d | D
|
|
406
|
-
* e | E
|
|
407
|
-
* f | F
|
|
408
|
-
* g | G
|
|
409
|
-
* h | H
|
|
410
|
-
* i | I
|
|
411
|
-
* j | J
|
|
412
|
-
* k | K
|
|
413
|
-
* l | L
|
|
414
|
-
* m | M
|
|
415
|
-
* n | N
|
|
416
|
-
* o | O
|
|
417
|
-
* p | P
|
|
418
|
-
* q | Q
|
|
419
|
-
* r | R
|
|
420
|
-
* s | S
|
|
421
|
-
* t | T
|
|
422
|
-
* u | U
|
|
423
|
-
* v | V
|
|
424
|
-
* w | W
|
|
425
|
-
* x | X
|
|
426
|
-
* y | Y
|
|
427
|
-
* z | Z
|
|
428
|
-
* Windows Key / Left ⌘ / Chromebook Search key | Windows Key / Left Command ⌘ / Chromebook Search Key
|
|
429
|
-
* right window key | Right Windows Key
|
|
430
|
-
* Windows Menu / Right ⌘ | Windows Menu / Right Command ⌘
|
|
431
|
-
* numpad 0 | Numpad 0
|
|
432
|
-
* numpad 1 | Numpad 1
|
|
433
|
-
* numpad 2 | Numpad 2
|
|
434
|
-
* numpad 3 | Numpad 3
|
|
435
|
-
* numpad 4 | Numpad 4
|
|
436
|
-
* numpad 5 | Numpad 5
|
|
437
|
-
* numpad 6 | Numpad 6
|
|
438
|
-
* numpad 7 | Numpad 7
|
|
439
|
-
* numpad 8 | Numpad 8
|
|
440
|
-
* numpad 9 | Numpad 9
|
|
441
|
-
* multiply | Multiply
|
|
442
|
-
* add | Add
|
|
443
|
-
* numpad period (firefox) | Numpad Period (Firefox)
|
|
444
|
-
* subtract | Subtract
|
|
445
|
-
* decimal point | Decimal Point
|
|
446
|
-
* divide | Divide
|
|
447
|
-
* f1 | F1
|
|
448
|
-
* f2 | F2
|
|
449
|
-
* f3 | F3
|
|
450
|
-
* f4 | F4
|
|
451
|
-
* f5 | F5
|
|
452
|
-
* f6 | F6
|
|
453
|
-
* f7 | F7
|
|
454
|
-
* f8 | F8
|
|
455
|
-
* f9 | F9
|
|
456
|
-
* f10 | F10
|
|
457
|
-
* f11 | F11
|
|
458
|
-
* f12 | F12
|
|
459
|
-
* f13 | F13
|
|
460
|
-
* f14 | F14
|
|
461
|
-
* f15 | F15
|
|
462
|
-
* f16 | F16
|
|
463
|
-
* f17 | F17
|
|
464
|
-
* f18 | F18
|
|
465
|
-
* f19 | F19
|
|
466
|
-
* f20 | F20
|
|
467
|
-
* f21 | F21
|
|
468
|
-
* f22 | F22
|
|
469
|
-
* f23 | F23
|
|
470
|
-
* f24 | F24
|
|
471
|
-
* num lock | Num Lock
|
|
472
|
-
* scroll lock | Scroll Lock
|
|
473
|
-
* ^ | Caret
|
|
474
|
-
* ! | Exclamation Point
|
|
475
|
-
* # | Hash
|
|
476
|
-
* $ | Dollar Sign
|
|
477
|
-
* ù | Grave Accent U
|
|
478
|
-
* page backward | Page Backward
|
|
479
|
-
* page forward | Page Forward
|
|
480
|
-
* closing paren (AZERTY) | Closing Parenthesis (AZERTY)
|
|
481
|
-
* * | Asterisk
|
|
482
|
-
* ~ + * key | Tilde + Asterisk Key
|
|
483
|
-
* minus (firefox), mute/unmute | Minus (Firefox), Mute/Unmute
|
|
484
|
-
* decrease volume level | Decrease Volume Level
|
|
485
|
-
* increase volume level | Increase Volume Level
|
|
486
|
-
* next | Next
|
|
487
|
-
* previous | Previous
|
|
488
|
-
* stop | Stop
|
|
489
|
-
* play/pause | Play/Pause
|
|
490
|
-
* e-mail | Email
|
|
491
|
-
* mute/unmute (firefox) | Mute/Unmute (Firefox)
|
|
492
|
-
* decrease volume level (firefox) | Decrease Volume Level (Firefox)
|
|
493
|
-
* increase volume level (firefox) | Increase Volume Level (Firefox)
|
|
494
|
-
* semi-colon / ñ | Semicolon / ñ
|
|
495
|
-
* equal sign | Equal Sign
|
|
496
|
-
* comma | Comma
|
|
497
|
-
* dash | Dash
|
|
498
|
-
* period | Period
|
|
499
|
-
* forward slash / ç | Forward Slash / ç
|
|
500
|
-
* grave accent / ñ / æ | Grave Accent / ñ / æ
|
|
501
|
-
* ?, / or ° | ?, / or °
|
|
502
|
-
* numpad period (chrome) | Numpad Period (Chrome)
|
|
503
|
-
* open bracket | Open Bracket
|
|
504
|
-
* back slash | Backslash
|
|
505
|
-
* close bracket / å | Close Bracket / å
|
|
506
|
-
* single quote / ø | Single Quote / ø
|
|
507
|
-
* \` | Backtick
|
|
508
|
-
* left or right ⌘ key (firefox) | Left or Right Command Key (Firefox)
|
|
509
|
-
* altgr | AltGr
|
|
510
|
-
* < /git > | < /git >
|
|
511
|
-
* GNOME Compose Key | GNOME Compose Key
|
|
512
|
-
* ç | ç
|
|
513
|
-
* XF86Forward | XF86Forward
|
|
514
|
-
* XF86Back | XF86Back
|
|
515
|
-
* alphanumeric | Alphanumeric
|
|
516
|
-
* hiragana/katakana | Hiragana/Katakana
|
|
517
|
-
* half-width/full-width | Half-Width/Full-Width
|
|
518
|
-
* kanji | Kanji
|
|
519
|
-
* toggle touchpad | Toggle Touchpad
|
|
520
|
-
*
|
|
521
|
-
* @title Set Inputs
|
|
522
|
-
* @method setInputs(inputs)
|
|
523
|
-
* @param {object} inputs
|
|
524
|
-
* @memberof KeyboardControls
|
|
525
|
-
*/
|
|
526
|
-
setInputs(inputs: Controls): void;
|
|
527
|
-
get options(): Controls;
|
|
528
218
|
}
|
|
529
|
-
export {};
|
|
530
219
|
//# sourceMappingURL=KeyboardControls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyboardControls.d.ts","sourceRoot":"","sources":["../../src/directives/KeyboardControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"KeyboardControls.d.ts","sourceRoot":"","sources":["../../src/directives/KeyboardControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAElF,oBAAY,KAAK;IACb,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,gBAAgB;IACrB,QAAQ,cAAc;IACtB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,aAAa,mBAAmB;IAChC,KAAK,UAAU;IACf,MAAM,YAAY;IAClB,QAAQ,cAAc;IACtB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,IAAI,IAAI;IACR,EAAE,IAAI;IACN,KAAK,IAAI;IACT,IAAI,IAAI;IACR,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,WAAW,iBAAiB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,MAAM;IACV,GAAG,MAAM;IACT,GAAG,MAAM;IACT,KAAK,MAAM;IACX,IAAI,MAAM;IACV,IAAI,MAAM;IACV,GAAG,MAAM;IACT,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,IAAI,MAAM;IACV,KAAK,MAAM;IACX,SAAS,gCAAgC;IACzC,QAAQ,MAAM;IACd,MAAM,qBAAqB;IAC3B,IAAI,WAAM;IACV,EAAE,MAAM;IACR,CAAC,MAAM;IACP,CAAC,M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@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Directive } from '../engine/directive';
|
|
3
|
+
import { Element } from '../engine/reactive';
|
|
4
|
+
import { Trigger } from '../engine/trigger';
|
|
5
|
+
import { SignalOrPrimitive } from '../components/types';
|
|
6
|
+
|
|
7
|
+
export type ShakeProps = {
|
|
8
|
+
/**
|
|
9
|
+
* Trigger that activates the shake animation
|
|
10
|
+
* When the trigger is activated, the shake animation will start
|
|
11
|
+
*/
|
|
12
|
+
trigger?: Trigger<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Intensity of the shake effect (in pixels)
|
|
15
|
+
* @default 10
|
|
16
|
+
*/
|
|
17
|
+
intensity?: SignalOrPrimitive<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Duration of the shake animation in milliseconds
|
|
20
|
+
* @default 500
|
|
21
|
+
*/
|
|
22
|
+
duration?: SignalOrPrimitive<number>;
|
|
23
|
+
/**
|
|
24
|
+
* Number of shake oscillations during the animation
|
|
25
|
+
* Higher values create more rapid shaking
|
|
26
|
+
* @default 10
|
|
27
|
+
*/
|
|
28
|
+
frequency?: SignalOrPrimitive<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Direction of the shake: 'x', 'y', or 'both'
|
|
31
|
+
* @default 'both'
|
|
32
|
+
*/
|
|
33
|
+
direction?: SignalOrPrimitive<'x' | 'y' | 'both'>;
|
|
34
|
+
/**
|
|
35
|
+
* Callback function called when shake starts
|
|
36
|
+
*/
|
|
37
|
+
onStart?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Callback function called when shake completes
|
|
40
|
+
*/
|
|
41
|
+
onComplete?: () => void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Shake directive that animates a display object's position when a trigger is activated.
|
|
45
|
+
* Creates a shake effect by rapidly oscillating the x and/or y position.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Basic usage with trigger
|
|
50
|
+
* const shakeTrigger = trigger();
|
|
51
|
+
*
|
|
52
|
+
* onMount(element) {
|
|
53
|
+
* // Element will shake when trigger is activated
|
|
54
|
+
* element.props.shake = { trigger: shakeTrigger };
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Trigger the shake
|
|
58
|
+
* shakeTrigger.start();
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class Shake extends Directive {
|
|
62
|
+
private elementRef;
|
|
63
|
+
private originalPosition;
|
|
64
|
+
private progressSignal;
|
|
65
|
+
private shakeSubscription;
|
|
66
|
+
private positionEffect;
|
|
67
|
+
private currentShakeConfig;
|
|
68
|
+
/**
|
|
69
|
+
* Initializes the shake directive
|
|
70
|
+
* @param element - The element to attach the shake effect to
|
|
71
|
+
*/
|
|
72
|
+
onInit(element: Element<Container>): void;
|
|
73
|
+
/**
|
|
74
|
+
* Mounts the shake directive and sets up trigger listener
|
|
75
|
+
* @param element - The element being mounted
|
|
76
|
+
*/
|
|
77
|
+
onMount(element: Element<Container>): void;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the shake props with default values
|
|
80
|
+
* @returns ShakeProps with defaults applied
|
|
81
|
+
*/
|
|
82
|
+
get shakeProps(): ShakeProps;
|
|
83
|
+
/**
|
|
84
|
+
* Performs the shake animation using animatedSignal
|
|
85
|
+
* @param data - Optional data passed from the trigger that can override default options
|
|
86
|
+
*/
|
|
87
|
+
private performShake;
|
|
88
|
+
/**
|
|
89
|
+
* Updates the shake directive when props change
|
|
90
|
+
* @param props - Updated props
|
|
91
|
+
*/
|
|
92
|
+
onUpdate(props: any): void;
|
|
93
|
+
/**
|
|
94
|
+
* Cleans up the shake directive
|
|
95
|
+
*/
|
|
96
|
+
onDestroy(): void;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=Shake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Shake.d.ts","sourceRoot":"","sources":["../../src/directives/Shake.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AAI,UAAU,CAQ3B;IAED;;;OAGG;YACW,YAAY;IAuG1B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG;IAUnB;;OAEG;IACH,SAAS;CA8BZ"}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './ControlsBase';
|
|
2
|
+
export * from './KeyboardControls';
|
|
3
|
+
export * from './GamepadControls';
|
|
4
|
+
export * from './Controls';
|
|
5
|
+
export * from './Scheduler';
|
|
6
|
+
export * from './ViewportFollow';
|
|
7
|
+
export * from './Sound';
|
|
8
|
+
export * from './Drag';
|
|
9
|
+
export * from './Transition';
|
|
10
|
+
export * from './Shake';
|
|
11
|
+
export * from './Flash';
|
|
2
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAEhC,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
package/dist/engine/trigger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface Listen<T = any> {
|
|
1
|
+
export interface Listen<T = any> {
|
|
2
2
|
config: T | undefined;
|
|
3
3
|
seed: {
|
|
4
4
|
config: T | undefined;
|
|
@@ -6,7 +6,7 @@ interface Listen<T = any> {
|
|
|
6
6
|
resolve: (value: any) => void;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
interface Trigger<T = any> {
|
|
9
|
+
export interface Trigger<T = any> {
|
|
10
10
|
start: () => Promise<void>;
|
|
11
11
|
listen: () => Listen<T> | undefined;
|
|
12
12
|
}
|
|
@@ -47,5 +47,4 @@ export declare function trigger<T = any>(globalConfig?: T): Trigger<T>;
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
export declare function on(triggerSignal: any, callback: (config: any) => void | Promise<void>): void;
|
|
50
|
-
export {};
|
|
51
50
|
//# sourceMappingURL=trigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/engine/trigger.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/engine/trigger.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,GAAG;IAC7B,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;IACtB,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;KAC/B,CAAC;CACH;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,GAAG;IAC9B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAEvD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA0B7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QAarF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/engine/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/engine/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE7C;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAiBvD;AAyBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEhD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,KAAK,EAAE,GAAG,EACV,eAAe,UAAQ,GACxB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA0BrB;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM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