so i’m trying to fade out all of my menu buttons at the same time when clicking on 1 of the menu buttons, but for some reason it’s only fading out the one i clicked on when it should fade out all my buttons at the same time when clicked.
Here’s the direct link to project :
https://thundros.github.io/menu-system-doosan/
Here’s the direct link to 'Button.js'
:
https://thundros.github.io/menu-system-doosan/src/Objects/Button.js
Here’s the direct link to 'TitleScene.js'
:
https://thundros.github.io/menu-system-doosan/src/Scenes/TitleScene.js
Here’s the code{s} in 'TitleScene.js'
to create the button{s}, Line{s} '85 - 106'
& '198 - 220'
:
CreateGameButton : function ( __objData ) {
this.__objData = __objData;
this.__buttons = new Button ( );
this.__buttons.CreateButton ({
scene : this.__objData.scene,
add : this.__objData.add,
x : this.__objData.x,
y : this.__objData.y,
key1 : this.__objData.key1,
key2 : this.__objData.key2,
text : this.__objData.text,
targetScene : this.__objData.targetScene,
locked : this.__objData.locked,
});
return this.__buttons;
},
in 'create ( )'
:
for ( this.__i = 0; this.__i <= 2; this.__i++ ) {
// Game
this.__button [ this.__i ] = this.CreateGameButton ({
scene : this.__scene, add : this.add, x : this.__buttonX [ this.__i ],
y : this.__buttonY [ this.__i ], key1 : this.__buttonKeys [ 0 ], key2 : this.__buttonKeys [ 1 ],
text : this.__buttonText [ this.__i ], targetScene : this.__buttonTargetScene [ this.__i ], locked : this.__buttonLocked [ this.__i ]
});
this.__buttonFadeInAlphaLevel [ this.__i ] = this.__fadeInMenu ( ).__buttonAlphaLevel [ this.__i ];
this.__buttonFadeInAlphaDuration [ this.__i ] = this.__fadeInMenu ( ).__buttonAlphaDuration [ this.__i ];
this.tweens.add ({
targets : this.__button [ this.__i ],
alpha : this.__buttonFadeInAlphaLevel [ this.__i ],
duration : this.__buttonFadeInAlphaDuration [ this.__i ],
});
this.__btnObjects.push ( this.__button [ this.__i ] );
console.log ( this.__button [ this.__i ] );
}
}
Here’s the code{s} in 'Button.js'
used to attempt to fade out all buttons :
In 'Button.js'
, Line{s} '63 - 78'
:
this.button.on ( 'pointerdown', function ( ) {
this.__scene.tweens.add ({
targets : [
this.button, this.__text,
],
targetScenes : this.__targetScene,
repeat : 0,
duration : 750,
alpha : { from : 1.0, to : 0.0 },
easeType : 'Linear',
yoyo : false,
onComplete : ( ) => {
this.__scene.scene.start ( this.__targetScene );
}
});
}.bind ( this ) );
Hopefully I explained correctly. If not, please do let me know & I will do my best to go into it in more depth.
Any help is as always, GREATLY appreciated!