BlueGit

blue-star speeltuin

Files

speeltuin / src / minigame / minigameInitialiser.js

minigameInitialiser.js

Oh boy tweening out the wazoo
timfa wsadhelios · pushed by timfa · 4 years ago
8b45c044 History
minigameInitialiser.js 1.0 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.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}