I have the following code where I am trying to add a few Kineticjs Layers to another Layer, but when I do nothing shows up at all. I have other shapes added to the canvas which show up fine, and if I add all the layers separately then they appear. Is this a bug or am I doing something wrong?
this.canvas = new Kinetic.Stage({ "container": jQuery( "#testElement" ).get(0),
"width": ShooterGame.WIDTH, "height": ShooterGame.HEIGHT });
this.container = new Kinetic.Layer();
this.layer1 = new Kinetic.Layer();
this.layer2 = new Kinetic.Layer();
this.layer3 = new Kinetic.Layer();
this.layer1Bg = new Kinetic.Rect({ "width": 100, "height": 100, "fill": "#FF0000" });
this.layer2Bg = new Kinetic.Rect({ "width": 100, "height": 100, "fill": "#FF0000" });
this.layer3Bg = new Kinetic.Rect({ "width": 100, "height": 100, "fill": "#FF0000" });
this.layer1.add( this.layer1Bg );
this.layer2.add( this.layer2Bg );
this.layer3.add( this.layer3Bg );
this.container.add( this.layer1 );
this.container.add( this.layer2 );
this.container.add( this.layer3 );
this.canvas.add( this.container );
this.container.draw();
You could add layers to a group (Kinetic.Group) and then add the group to the stage.