我试图同时使用HaxeUI和HaxeFlixel,但我获得的是HaxeUI在白色背景下的界面,覆盖了下面的所有内容。此外,即使在某种程度上可以使HaxeUI和HaxeFlixel协同工作,但当状态在HaxeFlixel中发生变化时,还不清楚如何更改HaxeUI的UI。下面是我使用的代码:
private function setupGame():Void {
Toolkit.theme = new GradientTheme();
Toolkit.init();
var stageWidth:Int = Lib.current.stage.stageWidth;
var stageHeight:Int = Lib.current.stage.stageHeight;
if (zoom == -1) {
var ratioX:Float = stageWidth / gameWidth;
var ratioY:Float = stageHeight / gameHeight;
zoom = Math.min(ratioX, ratioY);
gameWidth = Math.ceil(stageWidth / zoom);
gameHeight = Math.ceil(stageHeight / zoom);
}
trace('stage: ${stageWidth}x${stageHeight}, game: ${gameWidth}x${gameHeight}, zoom=$zoom');
addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
Toolkit.openFullscreen(function(root:Root) {
var view:IDisplayObject = Toolkit.processXmlResource("assets/xml/haxeui-resource.xml");
root.addChild(view);
});
}我可以猜到,HaxeUI和HaxeFlixel可能都有自己的主循环,它们的事件处理可能不兼容,但是以防万一,有人能有一个更明确的答案吗?
编辑:
实际上,使用openPopup要好得多:
Toolkit.openPopup( { x:20, y:150, width:100, height:100 }, function(root:Root) {
var view:IDisplayObject = Toolkit.processXmlResource("assets/xml/haxeui-naming.xml");
root.addChild(view);
});可以与屏幕的其余部分(用HaxeFlixel管理)进行交互,但是HaxeFlixel管理的屏幕部分中的鼠标指针仍然位于HaxeUI用户界面元素之下。
发布于 2015-08-22 15:26:54
当您使用haxeui打开全屏或弹出时,程序流将被阻塞(您的update()和with ()函数将不会被调用)。您可能应该转而看一下flixel-ui。
发布于 2015-09-26 06:24:36
当同时使用Flixel和HaxeUI时,几乎就像同时运行两个应用程序一样。但是,它们都依赖于OpenFL作为后端,并且各自都将自己附加到其显示树上。
我现在正在试验的一种技术是打开一个Flixel子状态,在子状态中调用Toolkit.openFullscreen()。从内部开始,您可以将根背景的alpha设置为0,这使您可以将其通过Flixel用于呈现的底层位图来查看。
下面是您如何将编辑器接口“嵌入”到Flixel子状态中的一个最小示例:
import haxe.ui.toolkit.core.Toolkit;
import haxe.ui.toolkit.core.RootManager;
import haxe.ui.toolkit.themes.DefaultTheme;
import flixel.FlxG;
import flixel.FlxSubState;
// This would typically be a Haxe UI XMLController
import app.MainEditor;
class HaxeUIState extends FlxSubState
{
override public function create()
{
super.create();
// Flixel uses a sprite-based cursor by default,
// so you need to enable the system cursor to be
// able to see what you're clicking.
FlxG.mouse.useSystemCursor = true;
Toolkit.theme = new DefaultTheme();
Toolkit.init();
Toolkit.openFullscreen(function (root) {
var editor = new MainEditor();
// Allows you to see what's going on in the sub state
root.style.backgroundAlpha = 0;
root.addChild(editor.view);
});
}
override public function destroy()
{
super.destroy();
// Switch back to Flixel's cursor
FlxG.mouse.useSystemCursor = true;
// Not sure if this is the "correct" way to close the UI,
// but it works for my purposes. Alternatively you could
// try opening the editor in advance, but hiding it
// until the sub-state opens.
RootManager.instance.destroyAllRoots();
}
// As far as I can tell, the update function continues to get
// called even while Haxe UI is open.
override public function update() {
super.update();
if (FlxG.keys.justPressed.ESCAPE) {
// This will implicitly trigger destroy().
close();
}
}
}这样,您可以将不同的Flixel状态与不同的Haxe控制器关联起来。(注:严格来说,它们不一定是亚州,这正是在我的情况下最有效的。)
发布于 2015-08-22 16:09:12
根据我的经验,haxeflixel和haxeui合作得很好,但它们是完全独立的项目,因此,flixel状态和显示UI之间的任何协调都必须由编码器添加。
我不记得您提到过的白色背景问题,除非haxeui root sprite有坚实的背景,否则不应该发生这种情况,在这种情况下,它应该针对haxeui项目维护者。
https://stackoverflow.com/questions/32150621
复制相似问题