hyperandroid / CAAT

Canvas Advanced Animation Toolkit
hyperandroid.github.com/CAAT
MIT License
727 stars 116 forks source link

AlphaBehavior on an ActorContainer does not affect children #122

Closed arnuschky closed 11 years ago

arnuschky commented 11 years ago

The code below does not fade in the children of the actor container. Instead, they appear on screen right away. Expected would be that the container and its children fade in together.

If I change the behavior to another one, ie a RotateBehavior, the code works as expected (and as described in the documentation): the behavior rotates the container and all its children.

            var background = (new CAAT.Actor()).
               setBackgroundImage("background", true).
               setScale(.8, .6);

            var someimage = (new CAAT.Actor()).
               setBackgroundImage("someimage", true);

            var container = (new CAAT.ActorContainer()).
               setSize(background.width, background.height).
               centerAt(director.width / 2.0, director.height / 2.0).
               enableEvents(false).
               addBehavior((new CAAT.AlphaBehavior()).
                  setValues(0, 1).
                  setFrameTime(scene.time, 3000).
                  setInterpolator((new CAAT.Interpolator).
                     createExponentialInInterpolator(6, false)));

            container.addChild(background);
            container.addChild(someimage);
hyperandroid commented 11 years ago

Alpha has two different ways of application:

2013/2/5 arnuschky notifications@github.com

The code below does not fade in the children of the actor container. Instead, they appear on screen right away. Expected would be that the container and its children fade in together.

If I change the behavior to another one, ie a RotateBehavior, the code works as expected (and as described in the documentation): the behavior rotates the container and all its children.

        var background = (new CAAT.Actor()).
           setBackgroundImage("background", true).
           setScale(.8, .6);

        var someimage = (new CAAT.Actor()).
           setBackgroundImage("someimage", true);

        var container = (new CAAT.ActorContainer()).
           setSize(background.width, background.height).
           centerAt(director.width / 2.0, director.height / 2.0).
           enableEvents(false).
           addBehavior((new CAAT.AlphaBehavior()).
              setValues(0, 1).
              setFrameTime(scene.time, 3000).
              setInterpolator((new CAAT.Interpolator).
                 createExponentialInInterpolator(6, false)));

        container.addChild(background);
        container.addChild(someimage);

— Reply to this email directly or view it on GitHubhttps://github.com/hyperandroid/CAAT/issues/122..

arnuschky commented 11 years ago

OK, great, that explains it. Must have missed that when I was browsing the code.

Thanks a bunch Arne

On Tue, 05 Feb 2013 11:08:48 -0800 Ibon Tolosana notifications@github.com wrote:

Alpha has two different ways of application:

  • not affecting children (default)
  • affect all children: call setGlobalAlpha(bool) on the container to enable it.
  • ibon

2013/2/5 arnuschky notifications@github.com

The code below does not fade in the children of the actor container. Instead, they appear on screen right away. Expected would be that the container and its children fade in together.

If I change the behavior to another one, ie a RotateBehavior, the code works as expected (and as described in the documentation): the behavior rotates the container and all its children.

        var background = (new CAAT.Actor()).
           setBackgroundImage("background", true).
           setScale(.8, .6);

        var someimage = (new CAAT.Actor()).
           setBackgroundImage("someimage", true);

        var container = (new CAAT.ActorContainer()).
           setSize(background.width, background.height).
           centerAt(director.width / 2.0, director.height /

2.0). enableEvents(false). addBehavior((new CAAT.AlphaBehavior()). setValues(0, 1). setFrameTime(scene.time, 3000). setInterpolator((new CAAT.Interpolator). createExponentialInInterpolator(6, false)));

        container.addChild(background);
        container.addChild(someimage);

— Reply to this email directly or view it on GitHubhttps://github.com/hyperandroid/CAAT/issues/122..


Reply to this email directly or view it on GitHub: https://github.com/hyperandroid/CAAT/issues/122#issuecomment-13145852