显示对象在NME 3.2.0中渲染的深度不正确。针对html5时
针对html5时,我对显示对象的绘图顺序有问题。请注意,如果我为flash编译,它将按预期工作。这个问题是如此基本,我很难相信这是NME的问题,但我缺少了一些关键的东西 假设NME的工作原理与Flash类似,那么下面的代码将生成一个红色矩形,上面有一个较小的蓝色矩形。但是,当我为html5构建时,红色矩形被绘制在顶部显示对象在NME 3.2.0中渲染的深度不正确。针对html5时,html,haxe,nme,Html,Haxe,Nme,针对html5时,我对显示对象的绘图顺序有问题。请注意,如果我为flash编译,它将按预期工作。这个问题是如此基本,我很难相信这是NME的问题,但我缺少了一些关键的东西 假设NME的工作原理与Flash类似,那么下面的代码将生成一个红色矩形,上面有一个较小的蓝色矩形。但是,当我为html5构建时,红色矩形被绘制在顶部 package; import nme.display.Bitmap; import nme.display.Shape; import nme.display.Sprite;
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(使用最新的Haxe) 在Jeash、Haxe Javascript库中仍然存在DisplayObjects排序问题,但目前仅当您希望以后重新排序对象时:
this.addChild(redBox);
this.addChild(blueBox);
this.swapChildren(blueBox, redBox);
我试图删除并再次添加显示对象,但不起作用。另外,setChildIndex不起作用(https://bugs.launchpad.net/jeash/+bug/1005791)。似乎升级到NME 3.4.3解决了它!(但升级带来了其他一些怪癖:-)