drgame-cc 1.0.45 → 1.0.46

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 (121) hide show
  1. package/drres/focus/focus_1/gesture.atlas +34 -0
  2. package/drres/focus/focus_1/gesture.atlas.meta +6 -0
  3. package/drres/focus/focus_1/gesture.json +1 -0
  4. package/drres/focus/focus_1/gesture.json.meta +10 -0
  5. package/drres/focus/focus_1/gesture.png +0 -0
  6. package/drres/{icons/pointer-yellow-60.png.meta → focus/focus_1/gesture.png.meta} +14 -14
  7. package/drres/focus/focus_1.meta +13 -0
  8. package/drres/focus/focus_2/gesture.atlas +41 -0
  9. package/drres/focus/focus_2/gesture.atlas.meta +6 -0
  10. package/drres/focus/focus_2/gesture.json +1 -0
  11. package/drres/focus/focus_2/gesture.json.meta +10 -0
  12. package/drres/focus/focus_2/gesture.png +0 -0
  13. package/drres/{icons/pointer-blue-60.png.meta → focus/focus_2/gesture.png.meta} +13 -13
  14. package/drres/focus/focus_2.meta +13 -0
  15. package/drres/focus/focus_3/gesture.atlas +34 -0
  16. package/drres/focus/focus_3/gesture.atlas.meta +6 -0
  17. package/drres/focus/focus_3/gesture.json +1 -0
  18. package/drres/focus/focus_3/gesture.json.meta +10 -0
  19. package/drres/focus/focus_3/gesture.png +0 -0
  20. package/drres/{icons/pointer-pink-60.png.meta → focus/focus_3/gesture.png.meta} +12 -12
  21. package/drres/focus/focus_3.meta +13 -0
  22. package/drres/focus/focus_4/gesture.atlas +20 -0
  23. package/drres/focus/focus_4/gesture.atlas.meta +6 -0
  24. package/drres/focus/focus_4/gesture.json +1 -0
  25. package/drres/focus/focus_4/gesture.json.meta +10 -0
  26. package/drres/focus/focus_4/gesture.png +0 -0
  27. package/drres/focus/focus_4/gesture.png.meta +38 -0
  28. package/drres/focus/focus_4.meta +13 -0
  29. package/drres/focus.meta +13 -0
  30. package/drres/prefab/ExitWin.prefab +2 -2
  31. package/drres/prefab/Toast.prefab +378 -378
  32. package/drscript/{ad/AdManager.ts.meta → BtnExtra.ts.meta} +1 -1
  33. package/drscript/Define.ts +17 -2
  34. package/drscript/{ad/AdSlot.ts.meta → Define.ts.meta} +1 -1
  35. package/drscript/{ad/AggregateAdProvider.ts.meta → ExitWin.ts.meta} +1 -1
  36. package/drscript/GameAnalytics.ts +37 -118
  37. package/drscript/{ad/IAdProvider.ts.meta → GameAnalytics.ts.meta} +1 -1
  38. package/drscript/HelperWin.ts.meta +10 -0
  39. package/drscript/Info.ts.meta +10 -0
  40. package/drscript/InternalUitl.ts.meta +10 -0
  41. package/drscript/KeyAdapter.ts +133 -0
  42. package/drscript/KeyAdapter.ts.meta +10 -0
  43. package/drscript/Loader.ts.meta +10 -0
  44. package/drscript/PlatformAdapter.ts +178 -192
  45. package/drscript/PlatformAdapter.ts.meta +10 -0
  46. package/drscript/README.md +91 -805
  47. package/drscript/README.md.meta +6 -0
  48. package/drscript/UIAdapter.ts +324 -0
  49. package/drscript/UIAdapter.ts.meta +10 -0
  50. package/drscript/WebBridge.ts +1 -1
  51. package/drscript/WebBridge.ts.meta +10 -0
  52. package/drscript/ad-sdk/reporters/superset-lewo.js +6 -0
  53. package/drscript/ad-sdk/types/enums.d.ts +1 -0
  54. package/drscript/ad-sdk.meta +13 -0
  55. package/drscript/ad.meta +13 -0
  56. package/drscript/component/AlertTip.ts +25 -0
  57. package/drscript/component/AlertTip.ts.meta +10 -0
  58. package/drscript/component/BtnExtra.ts +17 -0
  59. package/drscript/component/BtnExtra.ts.meta +10 -0
  60. package/drscript/{ExitWin.ts → component/ExitWin.ts} +6 -8
  61. package/drscript/component/ExitWin.ts.meta +10 -0
  62. package/drscript/{HelperWin.ts → component/HelperWin.ts} +5 -19
  63. package/drscript/component/HelperWin.ts.meta +10 -0
  64. package/drscript/component.meta +13 -0
  65. package/drscript/config.meta +13 -0
  66. package/drscript/core.meta +13 -0
  67. package/drscript/focus/FocusItem.ts +1 -19
  68. package/drscript/focus/FocusManager.ts +132 -170
  69. package/drscript/focus/FocusVisualLayer.ts +74 -163
  70. package/drscript/focus.meta +13 -0
  71. package/drscript/input/KeyboardMove.ts +40 -11
  72. package/drscript/input/KeyboardMove.ts.meta +10 -0
  73. package/drscript/input.meta +13 -0
  74. package/drscript/interface.meta +13 -0
  75. package/drscript/pinyin.meta +13 -0
  76. package/drscript/toast.meta +13 -0
  77. package/drscript/virtualgamepad.meta +13 -0
  78. package/package.json +1 -1
  79. package/drres/config/default.json +0 -108
  80. package/drres/config/default.json.meta +0 -6
  81. package/drres/icons/pointer-blue-60.png +0 -0
  82. package/drres/icons/pointer-pink-60.png +0 -0
  83. package/drres/icons/pointer-white-60.png +0 -0
  84. package/drres/icons/pointer-yellow-60.png +0 -0
  85. package/drscript/Info.ts +0 -78
  86. package/drscript/InternalUitl.ts +0 -65
  87. package/drscript/ad/AdManager.ts +0 -174
  88. package/drscript/ad/AdSlot.ts +0 -44
  89. package/drscript/ad/AggregateAdProvider.ts +0 -149
  90. package/drscript/ad/IAdProvider.ts +0 -39
  91. package/drscript/ad/MockAdProvider.ts +0 -36
  92. package/drscript/ad/MockAdProvider.ts.meta +0 -10
  93. package/drscript/ad/SelfAdProvider.ts +0 -41
  94. package/drscript/ad/SelfAdProvider.ts.meta +0 -10
  95. package/drscript/config/TvUiConfig.ts +0 -155
  96. package/drscript/config/TvUiConfig.ts.meta +0 -10
  97. package/drscript/config/TvUiConfigManager.ts +0 -133
  98. package/drscript/config/TvUiConfigManager.ts.meta +0 -10
  99. package/drscript/core/BackManager.ts +0 -38
  100. package/drscript/core/BackManager.ts.meta +0 -10
  101. package/drscript/core/NativeBridge.ts +0 -137
  102. package/drscript/core/NativeBridge.ts.meta +0 -10
  103. package/drscript/core/TvUi.ts +0 -69
  104. package/drscript/core/TvUi.ts.meta +0 -10
  105. package/drscript/core/TvUiRoot.ts +0 -137
  106. package/drscript/core/TvUiRoot.ts.meta +0 -10
  107. package/drscript/icon/IconConfig.ts +0 -7
  108. package/drscript/icon/IconConfig.ts.meta +0 -10
  109. package/drscript/icon/IconManager.ts +0 -97
  110. package/drscript/icon/IconManager.ts.meta +0 -10
  111. package/drscript/input/KeyCodeAdapter.ts +0 -23
  112. package/drscript/input/RemoteInputManager.ts +0 -105
  113. package/drscript/interface/ILobbyBridge.ts +0 -5
  114. package/drscript/toast/ToastComponent.ts +0 -35
  115. package/drscript/toast/ToastComponent.ts.meta +0 -10
  116. package/drscript/toast/ToastManager.ts +0 -66
  117. package/drscript/toast/ToastManager.ts.meta +0 -10
  118. package/drscript/toast/TvExitConfirmDialog.ts +0 -334
  119. package/drscript/toast/TvExitConfirmDialog.ts.meta +0 -10
  120. package/drscript/toast/UIFunctions.ts +0 -150
  121. package/drscript/toast/UIFunctions.ts.meta +0 -10
@@ -1,24 +1,45 @@
1
- import TvUiConfigManager from "../config/TvUiConfigManager";
2
- import { TvUiIconItem } from "../config/TvUiConfig";
3
- import IconManager from "../icon/IconManager";
1
+ import { FingerStyle } from "../Define";
4
2
  import FocusManager, { FocusRuntimeItem } from "./FocusManager";
5
3
 
6
4
  const { ccclass } = cc._decorator;
7
5
 
6
+ const FOCUS_STYLE_MAP: { [key: string]: string } = {
7
+ [FingerStyle.Default]: "focus_1",
8
+ [FingerStyle.White]: "focus_2",
9
+ [FingerStyle.Gold]: "focus_3",
10
+ [FingerStyle.Blue]: "focus_4",
11
+ };
12
+
8
13
  @ccclass
9
14
  export default class FocusVisualLayer extends cc.Component {
10
- private graphics: cc.Graphics | null = null;
11
- private iconNode: cc.Node | null = null;
12
- private iconSprite: cc.Sprite | null = null;
15
+ private static _style: FingerStyle = FingerStyle.Default;
16
+ private static _focusZIndex: number = 800;
17
+
18
+ public static get style(): FingerStyle {
19
+ return FocusVisualLayer._style;
20
+ }
21
+
22
+ public static setStyle(style: FingerStyle) {
23
+ FocusVisualLayer._style = style;
24
+ }
25
+
26
+ public static setFocusZIndex(z: number) {
27
+ FocusVisualLayer._focusZIndex = z;
28
+ }
29
+
30
+ private spineNode: cc.Node | null = null;
31
+ private spine: sp.Skeleton | null = null;
13
32
  private currentItem: FocusRuntimeItem | null = null;
14
- private currentIconConfig: TvUiIconItem | null = null;
15
33
  private inited: boolean = false;
34
+ private spineLoaded: boolean = false;
35
+ private static _focusEnabled: boolean = true;
16
36
 
17
37
  public static create(parent: cc.Node): FocusVisualLayer {
18
38
  let node = parent.getChildByName("FocusVisualLayer");
19
39
  if (!node) {
20
40
  node = new cc.Node("FocusVisualLayer");
21
- parent.addChild(node, 800);
41
+ parent.addChild(node, FocusVisualLayer._focusZIndex);
42
+ cc.game?.addPersistRootNode?.(node);
22
43
  }
23
44
  let layer = node.getComponent(FocusVisualLayer);
24
45
  if (!layer) layer = node.addComponent(FocusVisualLayer);
@@ -28,49 +49,53 @@ export default class FocusVisualLayer extends cc.Component {
28
49
 
29
50
  onDestroy() {
30
51
  FocusManager.offFocusChanged(this.onFocusChanged);
31
- TvUiConfigManager.offChanged(this.onConfigChanged);
32
52
  }
33
53
 
34
54
  public init() {
35
55
  if (this.inited) return;
36
56
  this.inited = true;
37
- this.node.zIndex = (TvUiConfigManager.getConfig().focus || {}).zIndex || 800;
57
+ this.node.zIndex = FocusVisualLayer._focusZIndex;
38
58
  this.resizeToParent();
39
59
  this.buildView();
60
+ this.loadSpine();
40
61
  FocusManager.onFocusChanged(this.onFocusChanged);
41
- TvUiConfigManager.onChanged(this.onConfigChanged);
42
62
  this.refresh(FocusManager.getCurrentFocusItem());
43
63
  }
44
64
 
45
- update() {
46
- if (!this.currentItem) return;
47
- this.drawFocus(this.currentItem);
48
- if (this.iconNode && this.iconNode.active && this.currentIconConfig) {
49
- this.positionIcon(this.currentItem, this.currentIconConfig);
50
- }
65
+ private onFocusChanged = (item: FocusRuntimeItem | null) => {
66
+ this.refresh(item);
51
67
  }
52
68
 
53
69
  private buildView() {
54
- if (!this.graphics) {
55
- this.graphics = this.node.addComponent(cc.Graphics);
56
- }
57
- if (!this.iconNode) {
58
- this.iconNode = new cc.Node("FocusIcon");
59
- this.iconNode.zIndex = 2;
60
- this.iconSprite = this.iconNode.addComponent(cc.Sprite);
61
- this.iconSprite.sizeMode = cc.Sprite.SizeMode.CUSTOM;
62
- this.node.addChild(this.iconNode, 2);
70
+ if (!this.spineNode) {
71
+ this.spineNode = new cc.Node("FocusSpine");
72
+ this.spineNode.zIndex = 2;
73
+ this.spine = this.spineNode.addComponent(sp.Skeleton);
74
+ this.spine.premultipliedAlpha = false;
75
+ this.node.addChild(this.spineNode);
76
+ this.spineNode.active = false;
63
77
  }
64
78
  this.node.active = false;
65
79
  }
66
80
 
67
- private onFocusChanged = (item: FocusRuntimeItem | null) => {
68
- this.refresh(item);
81
+ private getFocusPath(): string {
82
+ let folder = FOCUS_STYLE_MAP[FocusVisualLayer._style] || "focus_1";
83
+ return `drres/focus/${folder}/gesture`;
69
84
  }
70
85
 
71
- private onConfigChanged = () => {
72
- this.node.zIndex = (TvUiConfigManager.getConfig().focus || {}).zIndex || 800;
73
- this.refresh(this.currentItem);
86
+ private loadSpine() {
87
+ let path = this.getFocusPath();
88
+ cc.loader.loadRes(path, sp.SkeletonData, (error: Error, spData: sp.SkeletonData) => {
89
+ if (error || !this.spine) {
90
+ console.warn("[FocusVisualLayer] Load spine failed:", error);
91
+ return;
92
+ }
93
+ this.spine.skeletonData = spData;
94
+ this.spineLoaded = true;
95
+ if (this.currentItem) {
96
+ this.refresh(this.currentItem);
97
+ }
98
+ });
74
99
  }
75
100
 
76
101
  private refresh(item: FocusRuntimeItem | null) {
@@ -79,145 +104,39 @@ export default class FocusVisualLayer extends cc.Component {
79
104
  this.hide();
80
105
  return;
81
106
  }
107
+ if (!FocusVisualLayer._focusEnabled) {
108
+ this.hide();
109
+ return;
110
+ }
82
111
  this.node.active = true;
83
- this.drawFocus(item);
84
- this.refreshIcon(item);
112
+ this.updatePosition(item);
85
113
  }
86
114
 
87
115
  private hide() {
88
116
  this.node.active = false;
89
117
  this.currentItem = null;
90
- if (this.graphics) this.graphics.clear();
91
- if (this.iconNode) this.iconNode.active = false;
92
- this.currentIconConfig = null;
118
+ if (this.spineNode) this.spineNode.active = false;
93
119
  }
94
120
 
95
- // private drawFocus(item: FocusRuntimeItem) {
96
- // if (!item || !item.node || !item.node.isValid || !item.node.activeInHierarchy) {
97
- // this.hide();
98
- // return;
99
- // }
100
- // this.resizeToParent();
101
- // let focusConfig = TvUiConfigManager.getConfig().focus || {};
102
- // if (focusConfig.enabled === false) {
103
- // this.hide();
104
- // return;
105
- // }
106
- // if (!this.graphics) return;
107
- // this.graphics.clear();
108
- // if (focusConfig.frameEnabled !== true) {
109
- // return;
110
- // }
111
- // let box = item.node.getBoundingBoxToWorld();
112
- // let center = cc.v2(box.x + box.width / 2, box.y + box.height / 2);
113
- // let local = this.node.convertToNodeSpaceAR(center);
114
- // let padding = focusConfig.framePadding || 0;
115
- // this.graphics.lineWidth = focusConfig.lineWidth || 4;
116
- // this.graphics.strokeColor = this.parseColor(focusConfig.frameColor || "#ffd451", focusConfig.frameOpacity);
117
- // this.graphics.rect(local.x - box.width / 2 - padding, local.y - box.height / 2 - padding, box.width + padding * 2, box.height + padding * 2);
118
- // this.graphics.stroke();
119
- // }
120
-
121
- private refreshIcon(item: FocusRuntimeItem) {
122
- let iconKey = item.iconKey || (TvUiConfigManager.getConfig().focus || {}).defaultIconKey || "default";
123
- IconManager.getSpriteFrame(iconKey, (frame: cc.SpriteFrame | null, iconConfig?: TvUiIconItem | null) => {
124
- if (this.currentItem != item || !this.iconNode || !this.iconSprite) return;
125
- if (!frame) {
126
- this.iconNode.active = false;
127
- return;
128
- }
129
- this.iconNode.active = true;
130
- this.iconSprite.spriteFrame = frame;
131
- this.currentIconConfig = iconConfig || {};
132
- this.positionIcon(item, this.currentIconConfig);
133
- });
134
- }
121
+ private static readonly CURSOR_SCALE: number = 1.5;
135
122
 
136
- private drawFocus(item: FocusRuntimeItem) {
123
+ private updatePosition(item: FocusRuntimeItem) {
137
124
  if (!item || !item.node || !item.node.isValid || !item.node.activeInHierarchy) {
138
125
  this.hide();
139
126
  return;
140
127
  }
141
- this.resizeToParent();
142
- let focusConfig = TvUiConfigManager.getConfig().focus || {};
143
- if (focusConfig.enabled === false) {
144
- this.hide();
145
- return;
146
- }
147
- if (!this.graphics) return;
148
- this.graphics.clear();
149
- if (focusConfig.frameEnabled !== true) {
128
+ if (!this.spineLoaded || !this.spine || !this.spineNode) {
150
129
  return;
151
130
  }
152
-
153
- let node = item.node;
154
- let worldPos = node.parent.convertToWorldSpaceAR(node.position);
155
- let local = this.node.convertToNodeSpaceAR(worldPos);
156
-
157
- let contentSize = node.getContentSize();
158
- let scaleX = node.scaleX;
159
- let scaleY = node.scaleY;
160
- let width = contentSize.width * scaleX;
161
- let height = contentSize.height * scaleY;
162
-
163
- let padding = focusConfig.framePadding || 0;
164
- this.graphics.lineWidth = focusConfig.lineWidth || 4;
165
- this.graphics.strokeColor = this.parseColor(focusConfig.frameColor || "#ffd451", focusConfig.frameOpacity);
166
- this.graphics.rect(local.x - width / 2 - padding, local.y - height / 2 - padding, width + padding * 2, height + padding * 2);
167
- this.graphics.stroke();
168
- }
169
-
170
- // private positionIcon(item: FocusRuntimeItem, iconConfig: TvUiIconItem) {
171
- // if (!item || !item.node || !item.node.isValid) return;
172
- // let focusConfig = TvUiConfigManager.getConfig().focus || {};
173
-
174
- // let node = item.node;
175
- // let worldPos = node.parent.convertToWorldSpaceAR(node.position);
176
- // let local = this.node.convertToNodeSpaceAR(worldPos);
177
-
178
- // let contentSize = node.getContentSize();
179
- // let scaleX = node.scaleX;
180
- // let scaleY = node.scaleY;
181
- // let width = contentSize.width * scaleX;
182
- // let height = contentSize.height * scaleY;
183
-
184
- // let iconWidth = iconConfig.width || 60;
185
- // let iconHeight = iconConfig.height || 60;
186
- // let offsetX = iconConfig.offsetX;
187
- // let offsetY = iconConfig.offsetY;
188
- // if (offsetX === undefined) offsetX = focusConfig.iconOffsetX || 0;
189
- // if (offsetY === undefined) offsetY = focusConfig.iconOffsetY || 0;
190
- // if (!this.iconNode) return;
191
-
192
- // let x = local.x + width / 2 + offsetX;
193
- // let y = local.y + height / 2 + offsetY;
194
- // if ((focusConfig.iconPlacement || "bottomRight") == "bottomRight") {
195
- // y = local.y - height / 2 - offsetY;
196
- // }
197
- // this.iconNode.setContentSize(iconWidth, iconHeight);
198
- // this.iconNode.setPosition(x, y);
199
- // }
200
-
201
- private positionIcon(item: FocusRuntimeItem, iconConfig: TvUiIconItem) {
202
- if (!item || !item.node || !item.node.isValid) return;
203
- let focusConfig = TvUiConfigManager.getConfig().focus || {};
131
+ this.resizeToParent();
204
132
  let box = item.node.getBoundingBoxToWorld();
205
- let center = cc.v2(box.x + box.width / 2, box.y + box.height / 2);
206
- let local = this.node.convertToNodeSpaceAR(center);
207
- let width = iconConfig.width || 60;
208
- let height = iconConfig.height || 60;
209
- let offsetX = iconConfig.offsetX;
210
- let offsetY = iconConfig.offsetY;
211
- if (offsetX === undefined) offsetX = focusConfig.iconOffsetX || 0;
212
- if (offsetY === undefined) offsetY = focusConfig.iconOffsetY || 0;
213
- if (!this.iconNode) return;
214
- let x = local.x + box.width / 2 + offsetX;
215
- let y = local.y + box.height / 2 + offsetY;
216
- if ((focusConfig.iconPlacement || "bottomRight") == "bottomRight") {
217
- y = local.y - box.height / 2 - offsetY;
218
- }
219
- this.iconNode.setContentSize(width, height);
220
- this.iconNode.setPosition(x, y);
133
+ let bottomRight = cc.v2(box.x + box.width / 2 + 20, box.y + box.height / 2 - 20);
134
+ let local = this.node.convertToNodeSpaceAR(bottomRight);
135
+
136
+ this.spineNode.setPosition(local);
137
+ this.spineNode.setScale(FocusVisualLayer.CURSOR_SCALE);
138
+ this.spineNode.active = true;
139
+ this.spine.setAnimation(0, "gesture", true);
221
140
  }
222
141
 
223
142
  private resizeToParent() {
@@ -227,12 +146,4 @@ export default class FocusVisualLayer extends cc.Component {
227
146
  this.node.setContentSize(width, height);
228
147
  this.node.setPosition(0, 0);
229
148
  }
230
-
231
- private parseColor(hex: string, opacity?: number): cc.Color {
232
- hex = (hex || "#ffd451").replace("#", "");
233
- let r = parseInt(hex.substr(0, 2), 16);
234
- let g = parseInt(hex.substr(2, 2), 16);
235
- let b = parseInt(hex.substr(4, 2), 16);
236
- return cc.color(r || 255, g || 212, b || 81, opacity === undefined ? 230 : opacity);
237
- }
238
- }
149
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "bf5b7cab-c7bb-482b-8a70-47f0016d8e24",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -1,15 +1,44 @@
1
- import TvUi from "../core/TvUi";
2
- import { TvRemoteKey } from "./KeyCodeAdapter";
1
+ import { KeyCode } from "../ad-sdk/ad-sdk";
3
2
 
4
3
  const { ccclass, property } = cc._decorator;
5
4
 
5
+ const KEY_CODE_MAP: { [key: number]: string } = {
6
+ 19: KeyCode.Up,
7
+ 20: KeyCode.Down,
8
+ 21: KeyCode.Left,
9
+ 22: KeyCode.Right,
10
+ 23: KeyCode.Enter,
11
+ 37: KeyCode.Left,
12
+ 38: KeyCode.Up,
13
+ 39: KeyCode.Right,
14
+ 40: KeyCode.Down,
15
+ 0: KeyCode.Back,
16
+ 4: KeyCode.Back,
17
+ 6: KeyCode.Back,
18
+ 8: KeyCode.Back,
19
+ 13: KeyCode.Enter,
20
+ 27: KeyCode.Back,
21
+ 65: KeyCode.Left, // A
22
+ 66: KeyCode.Enter, // B
23
+ 80: KeyCode.Enter, // P (Pause)
24
+ 83: KeyCode.Down, // S
25
+ 87: KeyCode.Up, // W
26
+ 68: KeyCode.Right, // D
27
+ 1000: KeyCode.Left,
28
+ 1001: KeyCode.Right,
29
+ 1003: KeyCode.Up,
30
+ 1004: KeyCode.Down,
31
+ 1005: KeyCode.Enter,
32
+ 10009: KeyCode.Back,
33
+ };
34
+
6
35
  @ccclass
7
36
  export default class KeyboardMove extends cc.Component {
8
37
  /**
9
38
  * 按键移动回调
10
39
  */
11
40
  public callback: (dir: cc.Vec2) => void;
12
- private _keys: Set<TvRemoteKey> = new Set();
41
+ private _keys: Set<string> = new Set();
13
42
  private _dir: cc.Vec2 = cc.v2(0, 0);
14
43
 
15
44
  onLoad(): void {
@@ -24,13 +53,13 @@ export default class KeyboardMove extends cc.Component {
24
53
  }
25
54
 
26
55
  private onKeyDown(event: cc.Event.EventKeyboard): void {
27
- let key = TvUi.input.toRemoteKey(event.keyCode);
28
- this._keys.add(key);
56
+ let key = KEY_CODE_MAP[event.keyCode];
57
+ if (key) this._keys.add(key);
29
58
  }
30
59
 
31
60
  private onKeyUp(event: cc.Event.EventKeyboard): void {
32
- let key = TvUi.input.toRemoteKey(event.keyCode);
33
- this._keys.delete(key);
61
+ let key = KEY_CODE_MAP[event.keyCode];
62
+ if (key) this._keys.delete(key);
34
63
  }
35
64
 
36
65
  update(dt: number): void {
@@ -41,10 +70,10 @@ export default class KeyboardMove extends cc.Component {
41
70
  dir.x = 0;
42
71
  dir.y = 0;
43
72
 
44
- if (this._keys.has(TvRemoteKey.Left)) dir.x -= 1;
45
- if (this._keys.has(TvRemoteKey.Right)) dir.x += 1;
46
- if (this._keys.has(TvRemoteKey.Down)) dir.y -= 1;
47
- if (this._keys.has(TvRemoteKey.Up)) dir.y += 1;
73
+ if (this._keys.has(KeyCode.Left)) dir.x -= 1;
74
+ if (this._keys.has(KeyCode.Right)) dir.x += 1;
75
+ if (this._keys.has(KeyCode.Down)) dir.y -= 1;
76
+ if (this._keys.has(KeyCode.Up)) dir.y += 1;
48
77
 
49
78
  if (dir.x !== 0 || dir.y !== 0) {
50
79
  dir.normalizeSelf();
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "be2454bd-c5ec-42ed-aac1-53ed56bc537b",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "5fda29eb-7729-48f7-bbf0-15dcab3b9a41",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "73a70449-4adf-4062-a7ab-8ce5523ef0aa",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "dfb658d3-2629-4a95-9e58-8c14f0e6c268",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "bf7c86a2-3fc4-451e-94e6-3f0add364ef7",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "6a84303e-cf3d-4685-8a8b-b95042a9f40f",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drgame-cc",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "道然游戏适配包",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,108 +0,0 @@
1
- {
2
- "designWidth": 1920,
3
- "designHeight": 1080,
4
- "cpId": "ppl",
5
- "version": "1.0.0",
6
- "defaultScopeId": "page",
7
- "enableRemoteInput": true,
8
- "enableLifecycle": true,
9
- "focus": {
10
- "enabled": true,
11
- "frameEnabled": false,
12
- "framePadding": 10,
13
- "frameColor": "#ffd451",
14
- "frameOpacity": 230,
15
- "lineWidth": 5,
16
- "animationTime": 0.1,
17
- "defaultIconKey": "default",
18
- "iconPlacement": "bottomRight",
19
- "iconOffsetX": -20,
20
- "iconOffsetY": 20,
21
- "zIndex": 800
22
- },
23
- "icons": {
24
- "default": {
25
- "path": "drres/icons/pointer-yellow-60",
26
- "width": 60,
27
- "height": 60,
28
- "offsetX": -20,
29
- "offsetY": 20
30
- },
31
- "yellow": {
32
- "path": "drres/icons/pointer-yellow-60",
33
- "width": 60,
34
- "height": 60,
35
- "offsetX": -20,
36
- "offsetY": 20
37
- },
38
- "blue": {
39
- "path": "drres/icons/pointer-blue-60",
40
- "width": 60,
41
- "height": 60,
42
- "offsetX": -20,
43
- "offsetY": 20
44
- },
45
- "pink": {
46
- "path": "drres/icons/pointer-pink-60",
47
- "width": 60,
48
- "height": 60,
49
- "offsetX": -20,
50
- "offsetY": 20
51
- },
52
- "white": {
53
- "path": "drres/icons/pointer-white-60",
54
- "width": 60,
55
- "height": 60,
56
- "offsetX": -20,
57
- "offsetY": 20
58
- }
59
- },
60
- "adSdk": {
61
- "platform": "xiaomi"
62
- },
63
- "ads": {
64
- "reward": {
65
- "enabled": true,
66
- "mode": "reward",
67
- "channels": [
68
- {
69
- "type": "aggregate",
70
- "priority": 1,
71
- "rewardType": "reward"
72
- },
73
- {
74
- "type": "mock",
75
- "priority": 100
76
- }
77
- ]
78
- },
79
- "popup": {
80
- "enabled": true,
81
- "mode": "popup",
82
- "channels": [
83
- {
84
- "type": "aggregate",
85
- "priority": 1
86
- },
87
- {
88
- "type": "mock",
89
- "priority": 100
90
- }
91
- ]
92
- },
93
- "game": {
94
- "enabled": true,
95
- "mode": "popup",
96
- "channels": [
97
- {
98
- "type": "aggregate",
99
- "priority": 1
100
- },
101
- {
102
- "type": "mock",
103
- "priority": 100
104
- }
105
- ]
106
- }
107
- }
108
- }
@@ -1,6 +0,0 @@
1
- {
2
- "ver": "1.0.2",
3
- "uuid": "436a7017-623f-4fd3-9870-785af00d37ed",
4
- "importer": "json",
5
- "subMetas": {}
6
- }
Binary file
Binary file
Binary file
Binary file