Merge remote-tracking branch 'origin/master'
@@ -172,7 +172,7 @@ class GameObject
172
172
173
173
destroyed = false;
174
174
175
constructor (x, y, sprite, layer)
175
constructor (x, y, sprite, layer = 0)
176
176
{
177
177
this.transform = new Transform(this, x, y, 1, 1, 0);
178
178
this.renderer = new Renderer(this, sprite);
@@ -853,12 +853,20 @@ class Scene
853
853
}
854
854
this.game.removeScene(this);
855
855
856
this.context.clearRect(0, 0, this.real_size.x, this.real_size.y);
856
//this.context.clearRect(0, 0, this.real_size.x, this.real_size.y);
857
858
this.removeCanvas();
857
859
858
860
this.destroyed = true;
859
861
}
860
862
}
861
863
864
removeCanvas ()
865
{
866
var elem = document.getElementById(this.id);
867
return elem.parentNode.removeChild(elem);
868
}
869
862
870
backgroundColor =
863
871
{
864
872
r: 255,
@@ -981,6 +989,8 @@ class Scene
981
989
this.context.clearRect(0, 0, this.real_size.x, this.real_size.y);
982
990
}
983
991
992
this.activeObjects.sort((a, b) => a.layer - b.layer);
993
984
994
for (var i = 0; i < this.activeObjects.length; i++)
985
995
{
986
996
if (!this.activeObjects[i].destroyed && this.activeObjects[i].renderer.visible)
@@ -172,7 +172,7 @@ class GameObject172
172
173
destroyed = false;173
destroyed = false;174
174
175
constructor (x, y, sprite, layer)175
constructor (x, y, sprite, layer = 0)176
{176
{177
this.transform = new Transform(this, x, y, 1, 1, 0);177
this.transform = new Transform(this, x, y, 1, 1, 0);178
this.renderer = new Renderer(this, sprite);178
this.renderer = new Renderer(this, sprite);@@ -853,12 +853,20 @@ class Scene853
}853
}854
this.game.removeScene(this);854
this.game.removeScene(this);855
855
856
this.context.clearRect(0, 0, this.real_size.x, this.real_size.y);856
//this.context.clearRect(0, 0, this.real_size.x, this.real_size.y);857
858
this.removeCanvas();857
859
858
this.destroyed = true;860
this.destroyed = true;859
}861
}860
}862
}861
863
864
removeCanvas ()865
{866
var elem = document.getElementById(this.id);867
return elem.parentNode.removeChild(elem);868
}869
862
backgroundColor =870
backgroundColor =863
{871
{864
r: 255,872
r: 255,@@ -981,6 +989,8 @@ class Scene981
this.context.clearRect(0, 0, this.real_size.x, this.real_size.y);989
this.context.clearRect(0, 0, this.real_size.x, this.real_size.y);982
}990
}983
991
992
this.activeObjects.sort((a, b) => a.layer - b.layer);993
984
for (var i = 0; i < this.activeObjects.length; i++)994
for (var i = 0; i < this.activeObjects.length; i++)985
{995
{986
if (!this.activeObjects[i].destroyed && this.activeObjects[i].renderer.visible)996
if (!this.activeObjects[i].destroyed && this.activeObjects[i].renderer.visible)@@ -129,17 +129,7 @@ createMainScene = function (game)
129
129
chao = new Chao(Math.randomRange(0, 704), Math.randomRange(0, 640), game.images.chao_default, 0);
130
130
scene.addObject(chao);
131
131
132
scene.addObject(new MenuManager(0, 50, game.images.menuButton, 0));
132
scene.addObject(new MenuManager(0, 50, game.images.menuButton, 5));
133
133
134
134
WorldObjectTracker.Load(scene);
135
//createSubScene(scene);
136
135
};
137
138
createSubScene = function (scene)
139
{
140
var subScene = new FrogScene(200, 200, 416, 512, Scene.DisplayModes.absolute);
141
142
subScene.gameSpeed = 1;
143
144
scene.loadChildScene(subScene);
145
};
@@ -129,17 +129,7 @@ createMainScene = function (game)129
chao = new Chao(Math.randomRange(0, 704), Math.randomRange(0, 640), game.images.chao_default, 0);129
chao = new Chao(Math.randomRange(0, 704), Math.randomRange(0, 640), game.images.chao_default, 0);130
scene.addObject(chao);130
scene.addObject(chao);131
131
132
scene.addObject(new MenuManager(0, 50, game.images.menuButton, 0));132
scene.addObject(new MenuManager(0, 50, game.images.menuButton, 5));133
133
134
WorldObjectTracker.Load(scene);134
WorldObjectTracker.Load(scene);135
//createSubScene(scene);136
};135
};137
138
createSubScene = function (scene) 139
{140
var subScene = new FrogScene(200, 200, 416, 512, Scene.DisplayModes.absolute);141
142
subScene.gameSpeed = 1;143
144
scene.loadChildScene(subScene);145
};@@ -0,0 +1,34 @@
1
class MinigameInitialiser
2
{
3
static StartFrogGame (parentScene, originVector, originSize)
4
{
5
let subScene = new FrogScene(144, 64, 416, 512, Scene.DisplayModes.absolute);
6
7
let endPos = subScene.real_position.getCopy();
8
let endSize = subScene.real_size.getCopy();
9
10
subScene.position = originVector.getCopy();
11
subScene.size = originSize.getCopy();
12
13
this.WindowTween(subScene, endPos, endSize, 1000);
14
15
subScene.gameSpeed = 1;
16
17
parentScene.loadChildScene(subScene);
18
}
19
20
static WindowTween (scene, endPosition, endSize, length)
21
{
22
new TWEEN.Tween(scene.position)
23
.to({ x: endPosition.x, y: endPosition.y }, length)
24
.easing(TWEEN.Easing.Elastic.Out)
25
.onUpdate((s) => console.log(scene.position))
26
.start();
27
28
new TWEEN.Tween(scene.size)
29
.to({ x: endSize.x, y: endSize.y }, length)
30
.easing(TWEEN.Easing.Elastic.Out)
31
.onUpdate((s) => console.log(scene.position))
32
.start();
33
}
34
}
@@ -0,0 +1,34 @@1
class MinigameInitialiser 2
{3
static StartFrogGame (parentScene, originVector, originSize)4
{5
let subScene = new FrogScene(144, 64, 416, 512, Scene.DisplayModes.absolute);6
7
let endPos = subScene.real_position.getCopy();8
let endSize = subScene.real_size.getCopy();9
10
subScene.position = originVector.getCopy();11
subScene.size = originSize.getCopy();12
13
this.WindowTween(subScene, endPos, endSize, 1000);14
15
subScene.gameSpeed = 1;16
17
parentScene.loadChildScene(subScene);18
}19
20
static WindowTween (scene, endPosition, endSize, length)21
{22
new TWEEN.Tween(scene.position)23
.to({ x: endPosition.x, y: endPosition.y }, length)24
.easing(TWEEN.Easing.Elastic.Out)25
.onUpdate((s) => console.log(scene.position))26
.start();27
28
new TWEEN.Tween(scene.size)29
.to({ x: endSize.x, y: endSize.y }, length)30
.easing(TWEEN.Easing.Elastic.Out)31
.onUpdate((s) => console.log(scene.position))32
.start();33
}34
}