0
我在定位html5時遇到顯示對象的繪製順序問題。請注意,如果我爲閃光燈編譯,它按預期工作。這個問題非常基本,我很難相信這是NME的一個問題,而是我失蹤的一些重要問題。在NME 3.2.0中使用不正確的深度渲染DisplayObject。在定位html5時
假設NME的工作方式與Flash類似,那麼下面的代碼應該會產生一個紅色矩形,其上方有一個較小的藍色矩形。但是當我爲html5構建時,紅色矩形被繪製在頂部!
package;
import nme.display.Bitmap;
import nme.display.Shape;
import nme.display.Sprite;
import nme.display.StageAlign;
import nme.display.StageScaleMode;
import nme.events.Event;
import nme.Lib;
class Main extends Sprite
{
public function new() {
super();
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e) {
var redContainer : Sprite = new Sprite();
var redBox : Shape = new Shape();
redBox.graphics.beginFill(0xaa0000);
redBox.graphics.drawRect(0, 0, 100, 100);
var blueBox : Shape = new Shape();
blueBox.graphics.beginFill(0x0000aa);
blueBox.graphics.drawRect(0, 0, 50, 50);
// Add the sprite container
this.addChild(redContainer);
// Add a blue box, which should appear on top of the (empty) container
this.addChild(blueBox);
// Add a red box to the container.
// It should appear *below* the blue box since the container is below
// the blue box, but the red box is drawn on top of the blue box!
redContainer.addChild(redBox);
}
static public function main() {
Lib.current.addChild(new Main());
}
}
我在Chrome,Firefox和IE9中獲得相同的行爲。
好像升級到NME 3.4.3解決了它! (但升級引入了一些其他的怪癖:-) – Strille