0
我有以下代码,我正在尝试向另一个图层添加一些Kineticj图层,但是当我什么也没有显示时。我在画布上添加了其他形状,如果分开添加所有图层,它们就会出现。这是一个错误还是我做错了什么?将图层添加到另一个图层
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();
将图层放入另一个图层的目的是什么?将他们分组? – Delapouite 2012-08-16 05:53:29
是的,正好对了 – soulBit 2012-08-17 07:01:52