Director

Clear background

A CAAT.Director object will by default clean every frame the animations background.

Despite a Director object is an Actor, it will surpass the effects of calling either setFillStle( style ) or setBackgroundImage( image ) methods. The Director instance clears the background by calling rendering context's clearRect when using a Canvas renderer and gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT) if webGL is enabled. It has no effect when using the CSS renderer.

It will be a common error and performance sinker to let a canvas based director to clean the background once and doing it again in the scene. It is interesting al least during scene transition to have Director clear the screen since in can leave uncleared areas while scenes are brought in-out.

To avoid this you could call director's setClear(false).

It will be more proper to do it as follows:

                    scene.activated= function() {
                        director.setClear( CAAT.Foundation.Director.CLEAR_NONE );
                    };
                

Recently, CAAT has added more background clear modes. Right now, you can call director.setClear( CAAT.Director.CLEAR_XXX ).. Accepted values are:

  • CAAT.Director.CLEAR_NONE: the background is not cleared previous to draw a frame. Suitable when the scene has Actors which cover the whole background.
  • CAAT.Director.CLEAR_ALL: the background will be cleared previous to draw a frame.
  • CAAT.Director.CLEAR_DIRTY_RECTS: the background will be cleared and repainted only in dirty areas. These areas will be optimized. Consider switching from CLEAR_DIRTY_RECTS to CLEAR_ALL when there're many areas to repaint (8 or more).