Hi,
I am hoping someone here can help with 4 JavaScript warnings.
This issue for all 4 is that the variables are “Implicitly Declared”.
MIT Open Source Project Code Can Be Downloaded Below:
https://jesseleepalser.itch.io/t-crisis-v
Let me know how to fix the below, thanks!
Jesse
In “input.js” we declare the following two variables:
let MouseX = 0;
let MouseY = 0;
In “initialize.js” we access the two variables:
canvas.addEventListener("mousemove", function(event)
{
let canvas = document.getElementById("ScreenCanvas");
let rect = canvas.getBoundingClientRect();
// import { MouseX } from './input.js';
// import { MouseY } from './input.js';
MouseX = Math.floor(event.clientX - rect.left);
MouseX = (Math.floor(MouseX * (800 / BrowserWidth)));
MouseY = Math.floor(event.clientY - rect.top);
MouseY = (Math.floor(MouseY * (480 / BrowserHeight)));
});
I haven’t dealt with exporting variables before (only functions), so this is a new one to me.
Regardless of whether a variables is declared as ‘let’ or ‘const’, in the import module the variables are read-only
From MDN
The static import
declaration is used to import read-only live bindings which are exported by another module. The imported bindings are called live bindings because they are updated by the module that exported the binding, but cannot be re-assigned by the importing module.
So if you try
import { MouseX } from './input.js';
MouseX = some value here
It will throw a type error
TypeError: Assignment to constant variable.
Even though it was originally declared with let
.
However if you do the following
Export module
export let mouseX = 5;
export let mouseY = 10;
export const incMouseX = () => {
mouseX++;
}
export const incMouseY = () => {
mouseY++;
}
Import module
import { incMouseX, incMouseY, mouseX, mouseY } from './my-import.js';
console.log(mouseX, mouseY); // 5 10
incMouseX();
incMouseY();
console.log(mouseX, mouseY); // 6 11
You can see this confirms the read-only live bindings bit.
New to me as well.
The ‘Implicitly Declared’ global errors you are getting are because you have commented out the imports and are declaring MouseX and MouseY without ‘let’ or ‘const’
1 Like
Hi,
Thanks for the info…
In “input.js” I now have:
export let MouseX = 0;
export let MouseY = 0;
In “initialize.js” I now have:
canvas.addEventListener("mousemove", function(event)
{
let canvas = document.getElementById("ScreenCanvas");
let rect = canvas.getBoundingClientRect();
import { MouseX } from './input.js';
MouseX = Math.floor(event.clientX - rect.left);
import { MouseY } from './input.js';
MouseX = (Math.floor(MouseX * (800 / BrowserWidth)));
MouseY = Math.floor(event.clientY - rect.top);
MouseY = (Math.floor(MouseY * (480 / BrowserHeight)));
});
But now when I inspect the code, I have 7 errors and 319 weak warnings?
Source code can be downloaded below:
https://jesseleepalser.itch.io/t-crisis-v
Jesse
1. <b>JavaScript and TypeScript</b> group 7 errors 25 warnings 318 weak warnings
1. **General** group 7 errors 318 weak warnings
1. **Implicitly declared global JavaScript variable** inspection 118 weak warnings
1. file **data.js** 14 weak warnings
1. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
2. WEAK WARNING Variable GamepadUP implicitly declared
3. WEAK WARNING Variable GamepadRIGHT implicitly declared
4. WEAK WARNING Variable GamepadDOWN implicitly declared
5. WEAK WARNING Variable GamepadLEFT implicitly declared
6. WEAK WARNING Variable GamepadBUTTONONE implicitly declared
7. WEAK WARNING Variable GamepadBUTTONTWO implicitly declared
8. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
9. WEAK WARNING Variable GamepadUP implicitly declared
10. WEAK WARNING Variable GamepadRIGHT implicitly declared
11. WEAK WARNING Variable GamepadDOWN implicitly declared
12. WEAK WARNING Variable GamepadLEFT implicitly declared
13. WEAK WARNING Variable GamepadBUTTONONE implicitly declared
14. WEAK WARNING Variable GamepadBUTTONTWO implicitly declared
2. file **initialize.js** 7 weak warnings
1. WEAK WARNING Variable USBGamepadsSupported implicitly declared
2. WEAK WARNING Variable GamepadUP implicitly declared
3. WEAK WARNING Variable GamepadRIGHT implicitly declared
4. WEAK WARNING Variable GamepadDOWN implicitly declared
5. WEAK WARNING Variable GamepadLEFT implicitly declared
6. WEAK WARNING Variable GamepadBUTTONONE implicitly declared
7. WEAK WARNING Variable GamepadBUTTONTWO implicitly declared
3. file **interface.js** 34 weak warnings
1. WEAK WARNING Variable DelayAllUserInput implicitly declared
2. WEAK WARNING Variable DelayAllUserInput implicitly declared
3. WEAK WARNING Variable DelayAllUserInput implicitly declared
4. WEAK WARNING Variable DelayAllUserInput implicitly declared
5. WEAK WARNING Variable DelayAllUserInput implicitly declared
6. WEAK WARNING Variable DelayAllUserInput implicitly declared
7. WEAK WARNING Variable DelayAllUserInput implicitly declared
8. WEAK WARNING Variable DelayAllUserInput implicitly declared
9. WEAK WARNING Variable DelayAllUserInput implicitly declared
10. WEAK WARNING Variable DelayAllUserInput implicitly declared
11. WEAK WARNING Variable DelayAllUserInput implicitly declared
12. WEAK WARNING Variable DelayAllUserInput implicitly declared
13. WEAK WARNING Variable DelayAllUserInput implicitly declared
14. WEAK WARNING Variable DelayAllUserInput implicitly declared
15. WEAK WARNING Variable DelayAllUserInput implicitly declared
16. WEAK WARNING Variable DelayAllUserInput implicitly declared
17. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
18. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
19. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
20. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
21. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
22. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
23. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
24. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
25. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
26. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
27. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
28. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
29. WEAK WARNING Variable DelayAllUserInput implicitly declared
30. WEAK WARNING Variable DelayAllUserInput implicitly declared
31. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
32. WEAK WARNING Variable FirstHumanPlayerInput implicitly declared
33. WEAK WARNING Variable DelayAllUserInput implicitly declared
34. WEAK WARNING Variable DelayAllUserInput implicitly declared
4. file **logic.js** 1 weak warning
1. WEAK WARNING Variable Framerate implicitly declared
5. file **screens.js** 62 weak warnings
1. WEAK WARNING Variable NextSecond implicitly declared
2. WEAK WARNING Variable Gamepads implicitly declared
3. WEAK WARNING Variable DelayAllUserInput implicitly declared
4. WEAK WARNING Variable KeyboardCharacterPressed implicitly declared
5. WEAK WARNING Variable MouseButtonClicked implicitly declared
6. WEAK WARNING Variable VisualsLoaded implicitly declared
7. WEAK WARNING Variable AudioCacheLoaded implicitly declared
8. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
9. WEAK WARNING Variable GamepadConfigGetInput implicitly declared
10. WEAK WARNING Variable DelayAllUserInput implicitly declared
11. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
12. WEAK WARNING Variable GamepadConfigGetInput implicitly declared
13. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
14. WEAK WARNING Variable GamepadConfigGetInput implicitly declared
15. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
16. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
17. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
18. WEAK WARNING Variable GamepadConfigGetInput implicitly declared
19. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
20. WEAK WARNING Variable GamepadUP implicitly declared
21. WEAK WARNING Variable GamepadRIGHT implicitly declared
22. WEAK WARNING Variable GamepadDOWN implicitly declared
23. WEAK WARNING Variable GamepadLEFT implicitly declared
24. WEAK WARNING Variable GamepadBUTTONONE implicitly declared
25. WEAK WARNING Variable GamepadBUTTONTWO implicitly declared
26. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
27. WEAK WARNING Variable DelayAllUserInput implicitly declared
28. WEAK WARNING Variable GamepadUP implicitly declared
29. WEAK WARNING Variable DelayAllUserInput implicitly declared
30. WEAK WARNING Variable GamepadRIGHT implicitly declared
31. WEAK WARNING Variable DelayAllUserInput implicitly declared
32. WEAK WARNING Variable GamepadDOWN implicitly declared
33. WEAK WARNING Variable DelayAllUserInput implicitly declared
34. WEAK WARNING Variable GamepadLEFT implicitly declared
35. WEAK WARNING Variable DelayAllUserInput implicitly declared
36. WEAK WARNING Variable GamepadBUTTONONE implicitly declared
37. WEAK WARNING Variable DelayAllUserInput implicitly declared
38. WEAK WARNING Variable GamepadBUTTONTWO implicitly declared
39. WEAK WARNING Variable GamepadConfigGetInput implicitly declared
40. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
41. WEAK WARNING Variable DelayAllUserInput implicitly declared
42. WEAK WARNING Variable GamepadConfigPadIndex implicitly declared
43. WEAK WARNING Variable GamepadConfigGetInput implicitly declared
44. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
45. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
46. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
47. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
48. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
49. WEAK WARNING Variable KeyboardSpaceBarFunction implicitly declared
50. WEAK WARNING Variable DelayAllUserInput implicitly declared
51. WEAK WARNING Variable DelayAllUserInput implicitly declared
52. WEAK WARNING Variable DelayAllUserInput implicitly declared
53. WEAK WARNING Variable DelayAllUserInput implicitly declared
54. WEAK WARNING Variable DelayAllUserInput implicitly declared
55. WEAK WARNING Variable DelayAllUserInput implicitly declared
56. WEAK WARNING Variable Level0Video implicitly declared
57. WEAK WARNING Variable Level5Video implicitly declared
58. WEAK WARNING Variable Level10Video implicitly declared
59. WEAK WARNING Variable Level15Video implicitly declared
60. WEAK WARNING Variable Level20Video implicitly declared
61. WEAK WARNING Variable Level25Video implicitly declared
62. WEAK WARNING Variable Level30Video implicitly declared
2. **Unresolved reference** inspection 7 errors 200 weak warnings
1. file **initialize.js** 7 errors 16 weak warnings
1. WEAK WARNING Unresolved variable or type USBGamepadsSupported
2. WEAK WARNING Unresolved variable or type GamepadAxisOne
3. WEAK WARNING Unresolved variable or type GamepadUP
4. WEAK WARNING Unresolved variable or type GamepadAxisZero
5. WEAK WARNING Unresolved variable or type GamepadRIGHT
6. WEAK WARNING Unresolved variable or type GamepadAxisOne
7. WEAK WARNING Unresolved variable or type GamepadDOWN
8. WEAK WARNING Unresolved variable or type GamepadAxisZero
9. WEAK WARNING Unresolved variable or type GamepadLEFT
10. WEAK WARNING Unresolved variable or type GamepadButtonZero
11. WEAK WARNING Unresolved variable or type GamepadBUTTONONE
12. WEAK WARNING Unresolved variable or type GamepadButtonOne
13. WEAK WARNING Unresolved variable or type GamepadBUTTONTWO
14. WEAK WARNING Unresolved variable or type CheckForMouseButtonClick
15. WEAK WARNING Unresolved variable or type CheckForMouseButtonDown
16. WEAK WARNING Unresolved variable or type CheckForMouseButtonUp
17. WEAK WARNING Unresolved variable or type CheckForKeyPress
18. WEAK WARNING Unresolved variable or type CheckForKeyDown
19. WEAK WARNING Unresolved variable or type CheckForKeyRelease
20. WEAK WARNING Unresolved variable or type JoystickDirection
21. WEAK WARNING Unresolved variable or type CENTER
22. WEAK WARNING Unresolved variable or type JoystickButtonOne
23. WEAK WARNING Unresolved variable or type JoystickButtonTwo
2. file **interface.js** 100 weak warnings
1. WEAK WARNING Unresolved variable or type JoystickDirection
2. WEAK WARNING Unresolved variable or type JoystickDirection
3. WEAK WARNING Unresolved variable or type UP
4. WEAK WARNING Unresolved variable or type UP
5. WEAK WARNING Unresolved variable or type JoystickDirection
6. WEAK WARNING Unresolved variable or type JoystickDirection
7. WEAK WARNING Unresolved variable or type DOWN
8. WEAK WARNING Unresolved variable or type DOWN
9. WEAK WARNING Unresolved variable or type JoystickDirection
10. WEAK WARNING Unresolved variable or type JoystickDirection
11. WEAK WARNING Unresolved variable or type LEFT
12. WEAK WARNING Unresolved variable or type LEFT
13. WEAK WARNING Unresolved variable or type JoystickDirection
14. WEAK WARNING Unresolved variable or type JoystickDirection
15. WEAK WARNING Unresolved variable or type RIGHT
16. WEAK WARNING Unresolved variable or type RIGHT
17. WEAK WARNING Missing import statement
18. WEAK WARNING Missing import statement
19. WEAK WARNING Missing import statement
20. WEAK WARNING Missing import statement
21. WEAK WARNING Missing import statement
22. WEAK WARNING Missing import statement
23. WEAK WARNING Missing import statement
24. WEAK WARNING Missing import statement
25. WEAK WARNING Missing import statement
26. WEAK WARNING Missing import statement
27. WEAK WARNING Missing import statement
28. WEAK WARNING Missing import statement
29. WEAK WARNING Missing import statement
30. WEAK WARNING Missing import statement
31. WEAK WARNING Missing import statement
32. WEAK WARNING Missing import statement
33. WEAK WARNING Unresolved variable or type JoystickDirection
34. WEAK WARNING Unresolved variable or type JoystickDirection
35. WEAK WARNING Unresolved variable or type UP
36. WEAK WARNING Unresolved variable or type UP
37. WEAK WARNING Unresolved variable or type JoystickDirection
38. WEAK WARNING Unresolved variable or type JoystickDirection
39. WEAK WARNING Unresolved variable or type DOWN
40. WEAK WARNING Unresolved variable or type DOWN
41. WEAK WARNING Unresolved variable or type JoystickButtonOne
42. WEAK WARNING Unresolved variable or type JoystickButtonOne
43. WEAK WARNING Unresolved variable or type JoystickButtonOne
44. WEAK WARNING Unresolved variable or type JoystickButtonOne
45. WEAK WARNING Unresolved variable or type JoystickButtonOne
46. WEAK WARNING Unresolved variable or type JoystickButtonOne
47. WEAK WARNING Unresolved variable or type JoystickButtonOne
48. WEAK WARNING Unresolved variable or type JoystickButtonOne
49. WEAK WARNING Unresolved variable or type JoystickButtonOne
50. WEAK WARNING Unresolved variable or type JoystickButtonOne
51. WEAK WARNING Unresolved variable or type JoystickButtonOne
52. WEAK WARNING Unresolved variable or type JoystickButtonOne
53. WEAK WARNING Missing import statement
54. WEAK WARNING Missing import statement
55. WEAK WARNING Missing import statement
56. WEAK WARNING Missing import statement
57. WEAK WARNING Missing import statement
58. WEAK WARNING Missing import statement
59. WEAK WARNING Missing import statement
60. WEAK WARNING Missing import statement
61. WEAK WARNING Missing import statement
62. WEAK WARNING Missing import statement
63. WEAK WARNING Missing import statement
64. WEAK WARNING Missing import statement
65. WEAK WARNING Missing import statement
66. WEAK WARNING Missing import statement
67. WEAK WARNING Missing import statement
68. WEAK WARNING Missing import statement
69. WEAK WARNING Missing import statement
70. WEAK WARNING Missing import statement
71. WEAK WARNING Missing import statement
72. WEAK WARNING Missing import statement
73. WEAK WARNING Missing import statement
74. WEAK WARNING Missing import statement
75. WEAK WARNING Missing import statement
76. WEAK WARNING Missing import statement
77. WEAK WARNING Missing import statement
78. WEAK WARNING Missing import statement
79. WEAK WARNING Missing import statement
80. WEAK WARNING Missing import statement
81. WEAK WARNING Missing import statement
82. WEAK WARNING Missing import statement
83. WEAK WARNING Missing import statement
84. WEAK WARNING Missing import statement
85. WEAK WARNING Missing import statement
86. WEAK WARNING Missing import statement
87. WEAK WARNING Missing import statement
88. WEAK WARNING Missing import statement
89. WEAK WARNING Missing import statement
90. WEAK WARNING Missing import statement
91. WEAK WARNING Missing import statement
92. WEAK WARNING Missing import statement
93. WEAK WARNING Missing import statement
94. WEAK WARNING Missing import statement
95. WEAK WARNING Missing import statement
96. WEAK WARNING Missing import statement
97. WEAK WARNING Missing import statement
98. WEAK WARNING Missing import statement
99. WEAK WARNING Missing import statement
100. WEAK WARNING Missing import statement
3. file **logic.js** 22 weak warnings
1. WEAK WARNING Unresolved variable or type Browser
2. WEAK WARNING Unresolved variable or type JoystickDirection
3. WEAK WARNING Unresolved variable or type DOWN
4. WEAK WARNING Unresolved variable or type JoystickDirection
5. WEAK WARNING Unresolved variable or type UP
6. WEAK WARNING Unresolved variable or type JoystickDirection
7. WEAK WARNING Unresolved variable or type UP
8. WEAK WARNING Unresolved variable or type JoystickDirection
9. WEAK WARNING Unresolved variable or type UP
10. WEAK WARNING Unresolved variable or type JoystickDirection
11. WEAK WARNING Unresolved variable or type DOWN
12. WEAK WARNING Unresolved variable or type JoystickButtonOne
13. WEAK WARNING Unresolved variable or type JoystickButtonTwo
14. WEAK WARNING Unresolved variable or type JoystickDirection
15. WEAK WARNING Unresolved variable or type LEFT
16. WEAK WARNING Unresolved variable or type JoystickDirection
17. WEAK WARNING Unresolved variable or type RIGHT
18. WEAK WARNING Missing import statement
19. WEAK WARNING Missing import statement
20. WEAK WARNING Missing import statement
21. WEAK WARNING Missing import statement
22. WEAK WARNING Unresolved variable or type MouseButtonDown
4. file **screens.js** 61 weak warnings
1. WEAK WARNING Element is not exported
2. WEAK WARNING Unresolved function or method CheckForGamepadInput()
3. WEAK WARNING Element is not exported
4. WEAK WARNING Unresolved variable or type JoystickDirection
5. WEAK WARNING Unresolved variable or type JoystickButtonOne
6. WEAK WARNING Unresolved variable or type JoystickButtonTwo
7. WEAK WARNING Missing import statement
8. WEAK WARNING Missing import statement
9. WEAK WARNING Unresolved variable or type Browser
10. WEAK WARNING Unresolved variable or type JoystickDirection
11. WEAK WARNING Unresolved variable or type CENTER
12. WEAK WARNING Unresolved variable or type JoystickButtonOne
13. WEAK WARNING Unresolved variable or type JoystickButtonTwo
14. WEAK WARNING Unresolved variable or type JoystickDirection
15. WEAK WARNING Unresolved variable or type CENTER
16. WEAK WARNING Unresolved variable or type JoystickButtonOne
17. WEAK WARNING Unresolved variable or type JoystickButtonTwo
18. WEAK WARNING Unresolved variable or type JoystickDirection
19. WEAK WARNING Unresolved variable or type CENTER
20. WEAK WARNING Unresolved variable or type JoystickDirection
21. WEAK WARNING Unresolved variable or type JoystickDirection
22. WEAK WARNING Unresolved variable or type JoystickButtonOne
23. WEAK WARNING Unresolved variable or type JoystickButtonOne
24. WEAK WARNING Unresolved variable or type JoystickButtonOne
25. WEAK WARNING Unresolved variable or type JoystickButtonTwo
26. WEAK WARNING Unresolved variable or type JoystickButtonTwo
27. WEAK WARNING Unresolved variable or type JoystickButtonTwo
28. WEAK WARNING Unresolved variable or type JoystickButtonOne
29. WEAK WARNING Unresolved variable or type GamepadAxisOne
30. WEAK WARNING Unresolved variable or type GamepadAxisZero
31. WEAK WARNING Unresolved variable or type GamepadAxisOne
32. WEAK WARNING Unresolved variable or type GamepadAxisZero
33. WEAK WARNING Unresolved variable or type GamepadButtonZero
34. WEAK WARNING Unresolved variable or type GamepadButtonOne
35. WEAK WARNING Unresolved function or method QueryGamepadsForInput()
36. WEAK WARNING Unresolved variable or type Browser
37. WEAK WARNING Unresolved variable or type JoystickButtonOne
38. WEAK WARNING Unresolved variable or type JoystickButtonOne
39. WEAK WARNING Missing import statement
40. WEAK WARNING Missing import statement
41. WEAK WARNING Missing import statement
42. WEAK WARNING Missing import statement
43. WEAK WARNING Unresolved variable or type JoystickDirection
44. WEAK WARNING Unresolved variable or type UP
45. WEAK WARNING Unresolved variable or type JoystickDirection
46. WEAK WARNING Unresolved variable or type DOWN
47. WEAK WARNING Unresolved variable or type JoystickDirection
48. WEAK WARNING Unresolved variable or type LEFT
49. WEAK WARNING Unresolved variable or type JoystickDirection
50. WEAK WARNING Unresolved variable or type RIGHT
51. WEAK WARNING Unresolved variable or type JoystickButtonOne
52. WEAK WARNING Missing import statement
53. WEAK WARNING Missing import statement
54. WEAK WARNING Missing import statement
55. WEAK WARNING Missing import statement
56. WEAK WARNING Unresolved variable or type JoystickButtonOne
57. WEAK WARNING Unresolved variable or type JoystickButtonOne
58. WEAK WARNING Missing import statement
59. WEAK WARNING Missing import statement
60. WEAK WARNING Missing import statement
61. WEAK WARNING Missing import statement
5. file **visuals.js** 1 weak warning
1. WEAK WARNING Unresolved variable or type Browser
2. **Unused symbols** group 25 warnings
1. **Unused local symbol** inspection 25 warnings
1. file **initialize.js** 11 warnings
1. WARNING Unused local variable VisualsLoaded
2. WARNING Unused local variable AudioCacheLoaded
3. WARNING Unused local variable NextSecond
4. WARNING Unused local variable Level0Video
5. WARNING Unused local variable Level5Video
6. WARNING Unused local variable Level10Video
7. WARNING Unused local variable Level15Video
8. WARNING Unused local variable Level20Video
9. WARNING Unused local variable Level25Video
10. WARNING Unused local variable Level30Video
11. WARNING Unused function Init
2. file **input.js** 14 warnings
1. WARNING Unused local variable KeyboardSpaceBarFunction
2. WARNING Unused local variable USBGamepadsSupported
3. WARNING Unused local variable FirstHumanPlayerInput
4. WARNING Unused local variable GamepadConfigGetInput
5. WARNING Unused local variable GamepadAxisOne
6. WARNING Unused local variable GamepadButtonOne
7. WARNING Unused function CheckForMouseButtonClick
8. WARNING Unused function CheckForMouseButtonDown
9. WARNING Unused function CheckForMouseButtonUp
10. WARNING Unused function CheckForKeyPress
11. WARNING Unused function CheckForKeyDown
12. WARNING Unused function CheckForKeyRelease
13. WARNING Unused function CheckForGamepadInput
14. WARNING Unused function QueryGamepadsForInput
If you use so many global variables, you should really re-think your concept.
1 Like
Hi,
Yes, many global variables.
Can you provide another suggestion?
I need a way for information to be shared between JavaScript files…
Jesse
Create a class, create an instance an share the object. Then you can also modify the objects attributes in all files
Hi,
Ok, thanks - will research and implement JavaScript Classes…
Jesse
Hi,
I almost got it working with a new JavaScript Class.
New “classes.js” (Loaded first before all other scripts):
class InputClass {
constructor(MouseTouchX, MouseTouchY) {
this.MouseTouchX = 0;
this.MouseTouchY = 0;
}
}
const InputClassObject = new InputClass(0, 0);
“initialize.js”:
canvas.addEventListener("mousemove", function(event) {
let canvas = document.getElementById("ScreenCanvas");
let rect = canvas.getBoundingClientRect();
InputClassObject.MouseTouchX = Math.floor(event.clientX - rect.left);
InputClassObject.MouseTouchX = (Math.floor(InputClassObject.MouseTouchX * (800 / BrowserWidth)));
InputClassObject.MouseTouchY = Math.floor(event.clientY - rect.top);
InputClassObject.MouseTouchY = (Math.floor(InputClassObject.MouseTouchY * (480 / BrowserHeight)));
});
I am getting two warnings now:
Unused perimeter MouseTouchX
Unused perimeter MouseTouchY
in the following line:
constructor(MouseTouchX, MouseTouchY) {
Let me know, thanks!
Jesse
It’s what it says. You do not use the parameter in the constructor. If you don’t need them, remove them…
(or probably, the more useful correction… use them, assuming you dont want every object to initialize to 0,0…)