BlueGit

blue-star speeltuin

Oh boy tweening out the wazoo

timfa wsadhelios · pushed by timfa

Authored 2022-10-22 · 4 years ago

Hash
8b45c044a3980ad797fdea7d27d2f4071367a45c
Parent
42885b26
2 files changed +31 −3
src/minigame/minigameInitialiser.js +25 −2
@@ -1,11 +1,34 @@
1 1 class MinigameInitialiser
2 2 {
3 static StartFrogGame (parentScene)
3 static StartFrogGame (parentScene, originVector, originSize)
4 4 {
5 var subScene = new FrogScene(144, 64, 416, 512, Scene.DisplayModes.absolute);
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);
6 14
7 15 subScene.gameSpeed = 1;
8 16
9 17 parentScene.loadChildScene(subScene);
10 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 }
11 34 }
@@ -1,11 +1,34 @@
1class MinigameInitialiser
1class MinigameInitialiser
2{
2{
3 static StartFrogGame (parentScene)
3 static StartFrogGame (parentScene, originVector, originSize)
4 {
4 {
5 var subScene = new FrogScene(144, 64, 416, 512, Scene.DisplayModes.absolute);
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);
6
14
7 subScene.gameSpeed = 1;
15 subScene.gameSpeed = 1;
8
16
9 parentScene.loadChildScene(subScene);
17 parentScene.loadChildScene(subScene);
10 }
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 }
11}
34}
src/objects/menus/btnGames.js +6 −1
@@ -20,7 +20,12 @@ class BtnGames extends GameObject
20 20
21 21 initializeButtons ()
22 22 {
23 this.createSubButton(this.scene.game.images.btnFrog, function () { MinigameInitialiser.StartFrogGame(this.scene); MenuManager.Instance.moveToClose(); });
23 this.createSubButton(this.scene.game.images.btnFrog, function ()
24 {
25 MinigameInitialiser.StartFrogGame(this.scene, this.transform.position, this.transform.size);
26 MenuManager.Instance.moveToClose();
27
28 });
24 29
25 30 for (let i = 0; i < this.buttons.length; i++)
26 31 {
@@ -20,7 +20,12 @@ class BtnGames extends GameObject
20
20
21 initializeButtons ()
21 initializeButtons ()
22 {
22 {
23 this.createSubButton(this.scene.game.images.btnFrog, function () { MinigameInitialiser.StartFrogGame(this.scene); MenuManager.Instance.moveToClose(); });
23 this.createSubButton(this.scene.game.images.btnFrog, function ()
24 {
25 MinigameInitialiser.StartFrogGame(this.scene, this.transform.position, this.transform.size);
26 MenuManager.Instance.moveToClose();
27
28 });
24
29
25 for (let i = 0; i < this.buttons.length; i++)
30 for (let i = 0; i < this.buttons.length; i++)
26 {
31 {