BlueGit

timfa frameworkv3

fix preloadThenStart, fix clicky events

timfa Tim · pushed by timfa

Authored 2022-10-18 · 4 years ago

Hash
7cee40829561ed2b415aac382b892115f8362ae0
Parent
9dbbce66
2 files changed +5 −4
framework/engine/game.js +4 −3
@@ -17,14 +17,15 @@ class Game
17 17 GameInput.g_init();
18 18 }
19 19
20 preloadImagesThenStart(imageData)
20 preloadImagesThenStart(imageData, onComplete)
21 21 {
22 22 const cont = async () => {
23 await game.preloadImages(
23 await this.preloadImages(
24 24 imageData
25 25 );
26 26
27 game.startGame();
27 this.startGame();
28 onComplete && onComplete();
28 29 }
29 30
30 31 cont.apply();
@@ -17,14 +17,15 @@ class Game
17 GameInput.g_init();
17 GameInput.g_init();
18 }
18 }
19
19
20 preloadImagesThenStart(imageData)
20 preloadImagesThenStart(imageData, onComplete)
21 {
21 {
22 const cont = async () => {
22 const cont = async () => {
23 await game.preloadImages(
23 await this.preloadImages(
24 imageData
24 imageData
25 );
25 );
26
26
27 game.startGame();
27 this.startGame();
28 onComplete && onComplete();
28 }
29 }
29
30
30 cont.apply();
31 cont.apply();
framework/util/input.js +1 −1
@@ -77,7 +77,7 @@ var GameInput =
77 77 GameInput.trueMousePosition.y = e.y;
78 78 }
79 79
80 var el = document.getElementsByTagName("canvas")[0];
80 var el = document.getElementsByTagName("body")[0];
81 81 el.addEventListener("touchstart", function(){GameInput.g_mouseDownThisFrame = true;}, false);
82 82 el.addEventListener("touchend", function(){GameInput.g_mouseDownThisFrame = false;GameInput.g_mouseDown = false;}, false);
83 83 el.addEventListener("touchcancel", function(){GameInput.g_mouseDownThisFrame = false;GameInput.g_mouseDown = false;}, false);
@@ -77,7 +77,7 @@ var GameInput =
77 GameInput.trueMousePosition.y = e.y;
77 GameInput.trueMousePosition.y = e.y;
78 }
78 }
79
79
80 var el = document.getElementsByTagName("canvas")[0];
80 var el = document.getElementsByTagName("body")[0];
81 el.addEventListener("touchstart", function(){GameInput.g_mouseDownThisFrame = true;}, false);
81 el.addEventListener("touchstart", function(){GameInput.g_mouseDownThisFrame = true;}, false);
82 el.addEventListener("touchend", function(){GameInput.g_mouseDownThisFrame = false;GameInput.g_mouseDown = false;}, false);
82 el.addEventListener("touchend", function(){GameInput.g_mouseDownThisFrame = false;GameInput.g_mouseDown = false;}, false);
83 el.addEventListener("touchcancel", function(){GameInput.g_mouseDownThisFrame = false;GameInput.g_mouseDown = false;}, false);
83 el.addEventListener("touchcancel", function(){GameInput.g_mouseDownThisFrame = false;GameInput.g_mouseDown = false;}, false);