bard-legends-framework 0.4.6 → 0.4.7
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.
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Action } from 'actions-lib';
|
|
2
2
|
export declare class KeyboardService {
|
|
3
3
|
readonly keyPressed: Action<string>;
|
|
4
|
+
readonly keyReleased: Action<string>;
|
|
4
5
|
private listOfPressedKeys;
|
|
6
|
+
private listOfJustPressedKeys;
|
|
5
7
|
constructor();
|
|
6
8
|
isKeyDown(key: string): boolean;
|
|
9
|
+
isKeyJustPressed(key: string): boolean;
|
|
7
10
|
}
|
|
@@ -12,24 +12,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.KeyboardService = void 0;
|
|
13
13
|
const actions_lib_1 = require("actions-lib");
|
|
14
14
|
const service_1 = require("../../../game-entities/service/service");
|
|
15
|
+
const game_entities_1 = require("../../../game-entities");
|
|
15
16
|
let KeyboardService = class KeyboardService {
|
|
16
17
|
constructor() {
|
|
17
18
|
this.keyPressed = new actions_lib_1.Action();
|
|
19
|
+
this.keyReleased = new actions_lib_1.Action();
|
|
18
20
|
this.listOfPressedKeys = new Set();
|
|
21
|
+
this.listOfJustPressedKeys = new Set();
|
|
19
22
|
window.addEventListener('keydown', event => {
|
|
20
23
|
this.listOfPressedKeys.add(event.key);
|
|
24
|
+
this.listOfJustPressedKeys.add(event.key);
|
|
21
25
|
!event.repeat && this.keyPressed.trigger(event.key);
|
|
22
26
|
});
|
|
23
27
|
window.addEventListener('keyup', event => {
|
|
24
28
|
this.listOfPressedKeys.delete(event.key);
|
|
29
|
+
this.keyReleased.trigger(event.key);
|
|
25
30
|
});
|
|
26
31
|
window.addEventListener('blur', () => {
|
|
27
32
|
this.listOfPressedKeys.clear();
|
|
28
33
|
});
|
|
34
|
+
game_entities_1.UpdateCycle.afterSceneUpdateAction
|
|
35
|
+
.subscribe(() => {
|
|
36
|
+
this.listOfJustPressedKeys.clear();
|
|
37
|
+
})
|
|
38
|
+
.skipAttachCheck();
|
|
29
39
|
}
|
|
30
40
|
isKeyDown(key) {
|
|
31
41
|
return this.listOfPressedKeys.has(key);
|
|
32
42
|
}
|
|
43
|
+
isKeyJustPressed(key) {
|
|
44
|
+
return this.listOfJustPressedKeys.has(key);
|
|
45
|
+
}
|
|
33
46
|
};
|
|
34
47
|
exports.KeyboardService = KeyboardService;
|
|
35
48
|
exports.KeyboardService = KeyboardService = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.js","sourceRoot":"","sources":["../../../../src/pixi/services/keyboard/keyboard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAqC;AAErC,oEAA0E;
|
|
1
|
+
{"version":3,"file":"keyboard.js","sourceRoot":"","sources":["../../../../src/pixi/services/keyboard/keyboard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAqC;AAErC,oEAA0E;AAC1E,0DAAqD;AAG9C,IAAM,eAAe,GAArB,MAAM,eAAe;IAO1B;QANS,eAAU,GAAG,IAAI,oBAAM,EAAU,CAAC;QAClC,gBAAW,GAAG,IAAI,oBAAM,EAAU,CAAC;QAEpC,sBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;QACtC,0BAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;QAGhD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YACzC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1C,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CA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