2
\$\begingroup\$

In my cocos2d-iphone game, I have 2 backgrounds (CCnodes), each containing a quite complex hierarchy of sprites.

I would like to make a smooth transition between them:

  • Initially, only the first background is visible
  • At the end, only the second one is visible

Is there a good way to set the opacity of a full hierarchy of sprites ?

I tried to recursively set the opacity of all the contained sprites. It kinda works except that:

  • I guess it's not very efficient
  • I would like the opacity of overlapping sprites to be 'merged' (as if the background was one single big sprite)
\$\endgroup\$
3
  • \$\begingroup\$ You can render one node to a texture and render a sprite containing that texture some transparency on top of the other node \$\endgroup\$
    – rraallvv
    Commented Jan 8, 2013 at 4:40
  • \$\begingroup\$ But what if I have animations running on the children (translations, scaling,...) \$\endgroup\$
    – sdabet
    Commented Jan 8, 2013 at 7:26
  • \$\begingroup\$ wouldn't be any problem, all children would be rendered to the texture as normal. please see this related question stackoverflow.com/q/14073785/1436359 \$\endgroup\$
    – rraallvv
    Commented Jan 9, 2013 at 0:20

1 Answer 1

1
\$\begingroup\$

I finally solved it using a CCRenderTexture.

You can find the detailed explanation here: http://2sa-studio.blogspot.com/2013/01/fading-node-hierarchy-with.html

\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .