BlueGit

timfa frameworkv3

add link between scene and game

timfa Tim · pushed by timfa

Authored 2022-10-15 · 4 years ago

Hash
a2eec210148d0194d395c56866c9bdaecbc894b9
Parent
851ff372
3 files changed +11 −0
framework/engine/game.js +1 −0
@@ -12,6 +12,7 @@ class Game
12 12 loadScene(scene)
13 13 {
14 14 this.activeScenes.push(scene);
15 scene.Game = this;
15 16 }
16 17
17 18 update()
@@ -12,6 +12,7 @@ class Game
12 loadScene(scene)
12 loadScene(scene)
13 {
13 {
14 this.activeScenes.push(scene);
14 this.activeScenes.push(scene);
15 scene.Game = this;
15 }
16 }
16
17
17 update()
18 update()
framework/engine/image.js +2 −0
@@ -59,4 +59,6 @@ function image(url, subImgTotal, perRow)
59 59 context.globalAlpha = oldAlpha;
60 60 }
61 61 }
62
63 console.log("Image loaded: " + url);
62 64 }
@@ -59,4 +59,6 @@ function image(url, subImgTotal, perRow)
59 context.globalAlpha = oldAlpha;
59 context.globalAlpha = oldAlpha;
60 }
60 }
61 }
61 }
62
63 console.log("Image loaded: " + url);
62}
64}
framework/engine/scene.js +8 −0
@@ -13,6 +13,8 @@ class Scene
13 13 cv_context = null;
14 14 destroyed = false;
15 15
16 game = null;
17
16 18 constructor(x, y, width, height, fullscreen = false)
17 19 {
18 20 Scene.idCount++;
@@ -36,6 +38,12 @@ class Scene
36 38 this.cv_context = this.cv_canvas.getContext('2d');
37 39 }
38 40
41 loadChildScene(scene)
42 {
43 scene.parentScene = this;
44 this.game.loadScene(scene);
45 }
46
39 47 destroy()
40 48 {
41 49 this.destroyed = true
@@ -13,6 +13,8 @@ class Scene
13 cv_context = null;
13 cv_context = null;
14 destroyed = false;
14 destroyed = false;
15
15
16 game = null;
17
16 constructor(x, y, width, height, fullscreen = false)
18 constructor(x, y, width, height, fullscreen = false)
17 {
19 {
18 Scene.idCount++;
20 Scene.idCount++;
@@ -36,6 +38,12 @@ class Scene
36 this.cv_context = this.cv_canvas.getContext('2d');
38 this.cv_context = this.cv_canvas.getContext('2d');
37 }
39 }
38
40
41 loadChildScene(scene)
42 {
43 scene.parentScene = this;
44 this.game.loadScene(scene);
45 }
46
39 destroy()
47 destroy()
40 {
48 {
41 this.destroyed = true
49 this.destroyed = true