Jump to content

How to set same style to multiple elements with one line of code


Anahit DEV
 Share

Recommended Posts

Hello to all coders,

I need to add same styling to multiple elements/variables. How i can write the code/syntax in Phaser so i do that with one line of code not 100s lines for same thing. For example

 

basicTableJackpotSymbolOn.alpha = 0;
game.add.tween(basicTableJackpotSymbolOff).to({alpha: 1}, 500, "Linear", true);
basicTableBarSymbolOn.alpha = 0;
game.add.tween(basicTableBarSymbolOff).to({alpha: 1}, 500, "Linear", true);
basicTableMelonSymbolOn.alpha = 0;
		            	
basicBetYellowRectV2N3Point.fill = '#999999';
basicBetYellowRectV2N4Point.fill = '#999999';
basicBetYellowRectV2N5Point.fill = '#999999';
basicBetYellowRectV2N6Point.fill = '#999999';

 

Thanks in advance.

Link to comment
Share on other sites

 

 

Transforming is rotating scaling, positioning/moving your group. Yes you can definitely do that, but if you transform your group it might be that your sprites will not have the position that you pass as A parameter. This might not be your issue though. Do you have an example of your code?  

Link to comment
Share on other sites

Yes here it is @samid737

basicTableJackpotSymbol = game.add.sprite(0, 0, 'basicTableJackpotSymbol');
basicBetInnerWrapRect.addChild(basicTableJackpotSymbol);
basicTableJackpotSymbol.alignIn(basicBetLeftRectV1N2, Phaser.CENTER);
basicTableJackpotSymbol.frame = 0;

activateBasicPSymbols = game.add.group();
activateBasicPSymbols.addMultiple([basicTableJackpotSymbol,basicTableBarSymbol,basicTableMelonSymbol,basicTablePlumSymbol,basicTablePearSymbol,basicTableRaspberrySymbol,basicTableAppleSymbol,basicTableOrangeSymbol,basicTableLemonSymbol,basicTableCherrySymbol,basicTableSignSymbol], false);
activateBasicPSymbols.forEach(activateBasicPSymbolsFunc,this);
function activateBasicPSymbolsFunc(activatedSymbol){
	activatedSymbol.frame = 0;
};

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...