Anahit DEV

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

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.

Share this post


Link to post
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?  

Share this post


Link to post
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;
};

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.