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