BlueGit

blue-star speeltuin

fixed mess & made more mess

timfa Nick Hiert · pushed by timfa

Authored 2022-10-25 · 4 years ago

Hash
d2b34663fb113092ffeb320c38f41ce440af1b5b
Parent
f555b1c2
5 files changed +21 −21
src/minigame/frog/frogScene.js +2 −2
@@ -102,7 +102,7 @@ class FrogScene extends Scene
102 102 }
103 103 if (this.windowDestroyTweens.length > 0)
104 104 {
105 let frogButton = MainMenu.Instance.children.btnGames.children.btnFrog;
105 let frogButton = MainMenu.Instance.menu.children.btnGames.menu.children.btnFrog;
106 106 frogButton.moveToActiveState(800, () => frogButton.moveToInactiveState(800));
107 107
108 108 this.windowDestroyTweens.forEach(t => t.start());
@@ -129,7 +129,7 @@ class FrogScene extends Scene
129 129 passEatenFruitsToSimpleImagesRenderer ()
130 130 {
131 131
132 let targetButton = MainMenu.Instance.children.btnFruit;
132 let targetButton = MainMenu.Instance.menu.children.btnFruit;
133 133 let targetVector = targetButton.targetPosition;
134 134
135 135 this.eatenFruit.forEach(e =>
@@ -102,7 +102,7 @@ class FrogScene extends Scene
102 }
102 }
103 if (this.windowDestroyTweens.length > 0)
103 if (this.windowDestroyTweens.length > 0)
104 {
104 {
105 let frogButton = MainMenu.Instance.children.btnGames.children.btnFrog;
105 let frogButton = MainMenu.Instance.menu.children.btnGames.menu.children.btnFrog;
106 frogButton.moveToActiveState(800, () => frogButton.moveToInactiveState(800));
106 frogButton.moveToActiveState(800, () => frogButton.moveToInactiveState(800));
107
107
108 this.windowDestroyTweens.forEach(t => t.start());
108 this.windowDestroyTweens.forEach(t => t.start());
@@ -129,7 +129,7 @@ class FrogScene extends Scene
129 passEatenFruitsToSimpleImagesRenderer ()
129 passEatenFruitsToSimpleImagesRenderer ()
130 {
130 {
131
131
132 let targetButton = MainMenu.Instance.children.btnFruit;
132 let targetButton = MainMenu.Instance.menu.children.btnFruit;
133 let targetVector = targetButton.targetPosition;
133 let targetVector = targetButton.targetPosition;
134
134
135 this.eatenFruit.forEach(e =>
135 this.eatenFruit.forEach(e =>
src/objects/menus/1-baseMenu.js +11 −11
@@ -5,7 +5,7 @@ class BaseMenu
5 5 owner = null;
6 6
7 7 state = 0;
8 prevState = null;
8 prevState = 1;
9 9
10 10 isOpened = null;
11 11 isClosed = null;
@@ -23,12 +23,12 @@ class BaseMenu
23 23
24 24 openOnParentOpen ()
25 25 {
26 this.parent.isOpened.add(() => this.open(), this);
26 this.owner.parent.isOpened.add(() => this.open(), this);
27 27 }
28 28
29 29 closeOnParentClose ()
30 30 {
31 this.parent.isClosed.add(() => this.close(), this);
31 this.owner.parent.isClosed.add(() => this.close(), this);
32 32 }
33 33
34 34 init ()
@@ -37,15 +37,15 @@ class BaseMenu
37 37 this.isClosed = new Signal();
38 38 }
39 39
40 addChildButton (label, childButton)
40 addChildItem (label, childItem)
41 41 {
42 this.children[label] = childButton;
43 childButton.parent = this;
44 childButton.moveOnParentOpen();
45 childButton.moveOnParentClose();
46 if (childButton instanceof BaseMenu)
42 this.children[label] = childItem;
43 childItem.parent = this;
44 childItem.moveOnParentOpen();
45 childItem.moveOnParentClose();
46 if (childItem.menu && childItem.menu instanceof BaseMenu)
47 47 {
48 childButton.closeOnParentClose();
48 childItem.menu.closeOnParentClose();
49 49 }
50 50 }
51 51
@@ -79,7 +79,7 @@ class BaseMenu
79 79
80 80 close (callback)
81 81 {
82 if (this.state == MenuStates.closed || this.state == MenuStates.moving && this.prevState == MenuStates.open)
82 if (this.state == MenuStates.closed || (this.state == MenuStates.moving && this.prevState == MenuStates.open))
83 83 {
84 84 return;
85 85 }
@@ -5,7 +5,7 @@ class BaseMenu
5 owner = null;
5 owner = null;
6
6
7 state = 0;
7 state = 0;
8 prevState = null;
8 prevState = 1;
9
9
10 isOpened = null;
10 isOpened = null;
11 isClosed = null;
11 isClosed = null;
@@ -23,12 +23,12 @@ class BaseMenu
23
23
24 openOnParentOpen ()
24 openOnParentOpen ()
25 {
25 {
26 this.parent.isOpened.add(() => this.open(), this);
26 this.owner.parent.isOpened.add(() => this.open(), this);
27 }
27 }
28
28
29 closeOnParentClose ()
29 closeOnParentClose ()
30 {
30 {
31 this.parent.isClosed.add(() => this.close(), this);
31 this.owner.parent.isClosed.add(() => this.close(), this);
32 }
32 }
33
33
34 init ()
34 init ()
@@ -37,15 +37,15 @@ class BaseMenu
37 this.isClosed = new Signal();
37 this.isClosed = new Signal();
38 }
38 }
39
39
40 addChildButton (label, childButton)
40 addChildItem (label, childItem)
41 {
41 {
42 this.children[label] = childButton;
42 this.children[label] = childItem;
43 childButton.parent = this;
43 childItem.parent = this;
44 childButton.moveOnParentOpen();
44 childItem.moveOnParentOpen();
45 childButton.moveOnParentClose();
45 childItem.moveOnParentClose();
46 if (childButton instanceof BaseMenu)
46 if (childItem.menu && childItem.menu instanceof BaseMenu)
47 {
47 {
48 childButton.closeOnParentClose();
48 childItem.menu.closeOnParentClose();
49 }
49 }
50 }
50 }
51
51
@@ -79,7 +79,7 @@ class BaseMenu
79
79
80 close (callback)
80 close (callback)
81 {
81 {
82 if (this.state == MenuStates.closed || this.state == MenuStates.moving && this.prevState == MenuStates.open)
82 if (this.state == MenuStates.closed || (this.state == MenuStates.moving && this.prevState == MenuStates.open))
83 {
83 {
84 return;
84 return;
85 }
85 }
src/objects/menus/btnFruit.js +1 −1
@@ -9,7 +9,7 @@ class BtnFruit extends MoveableMenuItem
9 9
10 10 onClick (btns)
11 11 {
12 MainMenu.Instance.close();
12 MainMenu.Instance.menu.close();
13 13 this.fruitInventory.moveToOpen();
14 14 }
15 15 }
@@ -9,7 +9,7 @@ class BtnFruit extends MoveableMenuItem
9
9
10 onClick (btns)
10 onClick (btns)
11 {
11 {
12 MainMenu.Instance.close();
12 MainMenu.Instance.menu.close();
13 this.fruitInventory.moveToOpen();
13 this.fruitInventory.moveToOpen();
14 }
14 }
15}
15}
src/objects/menus/btnGames.js +2 −2
@@ -27,7 +27,7 @@ class BtnGames extends MoveableMenuItem
27 27 buttonFrog.onClick = function ()
28 28 {
29 29 MinigameInitialiser.StartFrogGame(this.scene, new vector(this.targetPosition.x - this.transform.size.x / 2, this.targetPosition.y - this.transform.size.y / 2), this.transform.size);
30 MainMenu.Instance.close();
30 MainMenu.Instance.menu.close();
31 31 };
32 32
33 33 buttonFrog.createActiveStateTween = function (time, onDone)
@@ -44,7 +44,7 @@ class BtnGames extends MoveableMenuItem
44 44 .easing(TWEEN.Easing.Quintic.Out);
45 45 };
46 46
47 this.menu.addChildButton("btnFrog", buttonFrog);
47 this.menu.addChildItem("btnFrog", buttonFrog);
48 48 }
49 49
50 50 getNextTargetPosition ()
@@ -27,7 +27,7 @@ class BtnGames extends MoveableMenuItem
27 buttonFrog.onClick = function ()
27 buttonFrog.onClick = function ()
28 {
28 {
29 MinigameInitialiser.StartFrogGame(this.scene, new vector(this.targetPosition.x - this.transform.size.x / 2, this.targetPosition.y - this.transform.size.y / 2), this.transform.size);
29 MinigameInitialiser.StartFrogGame(this.scene, new vector(this.targetPosition.x - this.transform.size.x / 2, this.targetPosition.y - this.transform.size.y / 2), this.transform.size);
30 MainMenu.Instance.close();
30 MainMenu.Instance.menu.close();
31 };
31 };
32
32
33 buttonFrog.createActiveStateTween = function (time, onDone)
33 buttonFrog.createActiveStateTween = function (time, onDone)
@@ -44,7 +44,7 @@ class BtnGames extends MoveableMenuItem
44 .easing(TWEEN.Easing.Quintic.Out);
44 .easing(TWEEN.Easing.Quintic.Out);
45 };
45 };
46
46
47 this.menu.addChildButton("btnFrog", buttonFrog);
47 this.menu.addChildItem("btnFrog", buttonFrog);
48 }
48 }
49
49
50 getNextTargetPosition ()
50 getNextTargetPosition ()
src/objects/menus/mainMenu.js +5 −5
@@ -25,7 +25,7 @@ class MainMenu extends MoveableMenuItem
25 25 this.menu.moveSelfOnOpen();
26 26 this.menu.moveSelfOnClose();
27 27
28 this.menu.open(() => this.menu.close());
28 //this.menu.open(() => this.menu.close());
29 29 }
30 30
31 31 onClick (btn)
@@ -36,16 +36,16 @@ class MainMenu extends MoveableMenuItem
36 36 initialiseChildren ()
37 37 {
38 38 let vectorOrigin = this.getNextOriginPosition();
39 this.menu.addChildButton("btnFruit", this.scene.addObject(new BtnFruit(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnFruit, 4)));
39 this.menu.addChildItem("btnFruit", this.scene.addObject(new BtnFruit(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnFruit, 4)));
40 40
41 41 vectorOrigin = this.getNextOriginPosition();
42 this.menu.addChildButton("btnToys", this.scene.addObject(new BtnToys(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnToys, 4)));
42 this.menu.addChildItem("btnToys", this.scene.addObject(new BtnToys(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnToys, 4)));
43 43
44 44 vectorOrigin = this.getNextOriginPosition();
45 this.menu.addChildButton("btnGames", this.scene.addObject(new BtnGames(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnGames, 4, true)));
45 this.menu.addChildItem("btnGames", this.scene.addObject(new BtnGames(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnGames, 4, true)));
46 46
47 47 vectorOrigin = this.getNextOriginPosition();
48 this.menu.addChildButton("btnPlants", this.scene.addObject(new BtnPlants(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnPlants, 4))
48 this.menu.addChildItem("btnPlants", this.scene.addObject(new BtnPlants(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnPlants, 4))
49 49 );
50 50
51 51 }
@@ -25,7 +25,7 @@ class MainMenu extends MoveableMenuItem
25 this.menu.moveSelfOnOpen();
25 this.menu.moveSelfOnOpen();
26 this.menu.moveSelfOnClose();
26 this.menu.moveSelfOnClose();
27
27
28 this.menu.open(() => this.menu.close());
28 //this.menu.open(() => this.menu.close());
29 }
29 }
30
30
31 onClick (btn)
31 onClick (btn)
@@ -36,16 +36,16 @@ class MainMenu extends MoveableMenuItem
36 initialiseChildren ()
36 initialiseChildren ()
37 {
37 {
38 let vectorOrigin = this.getNextOriginPosition();
38 let vectorOrigin = this.getNextOriginPosition();
39 this.menu.addChildButton("btnFruit", this.scene.addObject(new BtnFruit(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnFruit, 4)));
39 this.menu.addChildItem("btnFruit", this.scene.addObject(new BtnFruit(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnFruit, 4)));
40
40
41 vectorOrigin = this.getNextOriginPosition();
41 vectorOrigin = this.getNextOriginPosition();
42 this.menu.addChildButton("btnToys", this.scene.addObject(new BtnToys(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnToys, 4)));
42 this.menu.addChildItem("btnToys", this.scene.addObject(new BtnToys(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnToys, 4)));
43
43
44 vectorOrigin = this.getNextOriginPosition();
44 vectorOrigin = this.getNextOriginPosition();
45 this.menu.addChildButton("btnGames", this.scene.addObject(new BtnGames(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnGames, 4, true)));
45 this.menu.addChildItem("btnGames", this.scene.addObject(new BtnGames(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnGames, 4, true)));
46
46
47 vectorOrigin = this.getNextOriginPosition();
47 vectorOrigin = this.getNextOriginPosition();
48 this.menu.addChildButton("btnPlants", this.scene.addObject(new BtnPlants(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnPlants, 4))
48 this.menu.addChildItem("btnPlants", this.scene.addObject(new BtnPlants(vectorOrigin.x, vectorOrigin.y, this.targetPosition.x + this.buttonXOffset, vectorOrigin.y, this.scene.game.images.btnPlants, 4))
49 );
49 );
50
50
51 }
51 }