roscminni Posted October 13, 2013 Share Posted October 13, 2013 Hi, I'm just starting out with Phaser, really like it so far and have managed to figure most things out from the examples and this forum. I was wondering if there was any way to add a tween to a group? I am guessing you might use the forAll function, but I'm not sure how this works. This is what I would like to do:game.add.tween(titleScreen).to({alpha: 0},2000,Phaser.Easing.Linear.None,true);Where titleScreen is a group of sprites that comprise my title screen. Thanks, Anton Link to comment Share on other sites More sharing options...
roscminni Posted October 13, 2013 Author Share Posted October 13, 2013 By using an array I was able to fade out my title screen like so:var titleScreen = [elements];for(var i =0; i < titleScreen.length; i++){ game.add.tween(titleScreen[i]).to({alpha: 0},1000,Phaser.Easing.Linear.None,true);}; This is perhaps the best way to achieve what I need, however I would still like to know what is possible with the group object. Link to comment Share on other sites More sharing options...
Hsaka Posted October 13, 2013 Share Posted October 13, 2013 Hi, yes it's possible to tween a group object's alpha, but unfortunately, the alpha property is not exposed directly so you will have to do it like this:game.add.tween(titleScreen._container).to({alpha: 0},2000,Phaser.Easing.Linear.None,true); Link to comment Share on other sites More sharing options...
rich Posted October 13, 2013 Share Posted October 13, 2013 Group.alpha is a public property now (as of this morning!) which works if you want to fade a group out/in. But if you want to apply a tween to every child of the group there's no direct way at the moment, so you'd need to use one of the Group iteration methods (forEach perhaps) and apply them that way. Link to comment Share on other sites More sharing options...
roscminni Posted October 13, 2013 Author Share Posted October 13, 2013 Thanks Hsaka and Rich, ._container addition worked. I would like to learn more about how the group object works, but I will happily wait until the docs are done. Link to comment Share on other sites More sharing options...
Recommended Posts