Jump to content

Fade out a subset group fades all members of the superset group


Recommended Posts

I have this code: 

init: function () {

    screenObjects = gameObject.add.group();
    guidesGroup = gameObject.add.group();
create: function () {

guide1 = gameObject.add.sprite(0, 0, si.ImageAssetKeys.GUIDE_1_IMG);
guide1.name = 'guide1';

guide2 = gameObject.add.sprite(0, 0, si.ImageAssetKeys.GUIDE_2_IMG);
guide2.name = 'guide2';

guide3 = gameObject.add.sprite(0, 0, si.ImageAssetKeys.GUIDE_3_IMG);
guide3.name = 'guide3';

nextButton = si.SIButton.SIButton(360, 670, si.ImageAssetKeys.GUIDE_BUTTONS_SHEET, thisObject, click, 3, 2, 2, 3);

prevButton = si.SIButton.SIButton(10, 670, si.ImageAssetKeys.GUIDE_BUTTONS_SHEET, thisObject, click, 1, 0, 0, 1);


As you can see guides belong to screenObjects and guidesGroup groups, but previousButton and nextButton belong to only screenObjects. I am using this code to fade in/out guides in guidesGroup but the problem is the next and previous buttons are faded out as well.

guidesGroup.forEach(function (item) {
   var siObject = this;

   item.alpha = 0;
   if (item.name === 'guide1') {
        siObject.gameObject.add.tween(item).to({alpha: 1}, si.Const.FADE_DURATION, siObject.Const.TWEEN_LINEAR, true);
}, si);

Is there some mixing between game groups, are they distinct if same object belong to two groups?

Link to comment
Share on other sites

Wait, the addition of new objects has effect on what is on top of what?


is different than


With the first one guide5 is below prev and next buttons in screenObjects, in the second, guide5 i above prev and next buttons, so as it fades in buttons fade out :D i.e they are below guide5

What are Phaser groups actually, are the separated from each other?

Link to comment
Share on other sites

Is "screenObjects" a group? Display objects in Phaser can only have one parent at a time. If you add a sprite to Group A, then add the sprite to Group B, it will be removed from Group A and will only be in Group B.

This might explain some of the z-order stuff you're seeing that you asked about here: 


Link to comment
Share on other sites


  • Recently Browsing   0 members

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