BlueGit

blue-star speeltuin

Files

speeltuin / src / minigame / minigameInitialiser.js

minigameInitialiser.js

a743c0b9 History
minigameInitialiser.js 1.5 KiB Download Raw
1class 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.SpawnWindowTween(subScene, endPos, endSize, 1000);
14
15 subScene.gameSpeed = 1;
16
17 subScene.windowDestroyTweens = this.DestroyWindowTween(subScene, originVector, originSize, 600);
18
19 parentScene.loadChildScene(subScene);
20
21 subScene.setPrimary();
22 }
23
24
25 static SpawnWindowTween (scene, endPosition, endSize, length)
26 {
27 new TWEEN.Tween(scene.position)
28 .to({ x: endPosition.x, y: endPosition.y }, length)
29 .easing(TWEEN.Easing.Elastic.Out)
30 .start();
31
32 new TWEEN.Tween(scene.size)
33 .to({ x: endSize.x, y: endSize.y }, length)
34 .easing(TWEEN.Easing.Elastic.Out)
35 .start();
36 }
37
38
39 static DestroyWindowTween (scene, endPosition, endSize, length)
40 {
41 return [
42 new TWEEN.Tween(scene.position)
43 .to({ x: endPosition.x, y: endPosition.y }, length)
44 .easing(TWEEN.Easing.Cubic.Out),
45
46 new TWEEN.Tween(scene.size)
47 .to({ x: endSize.x, y: endSize.y }, length)
48 .easing(TWEEN.Easing.Cubic.Out)
49 ];
50 }
51}