所以我正在和Haxe和Haxepunk一起玩游戏。精细。除了当我导出到C++时,什么都没有渲染!我之前将此内容发布在Haxepunk板上,所以可以找到更多信息here。这是Haxepunk主题的摘录;

我仍然可以很好地进行编译,但是除了我定义的背景色之外,游戏中实际上没有任何渲染。控制台仍然可以正常工作并呈现良好的效果。 HaxePunk控制台告诉我Atlases using BitmapData will not be managed

我正在使用Ash的组件实体系统,而不是在使用Haxe的实体。相关对象具有附加的Visible组件,如下所示;

package game.component;

import com.haxepunk.Graphic;
import com.haxepunk.graphics.Image;

class Visible {

    public var image(default, default) : Graphic;

    public function new() {
        this.image = Image.createRect(16, 16, 0xFF0000);
    }
}

这就是相关的渲染系统;
package game.system;

import ash.core.Engine;
import ash.core.Entity;
import ash.core.System;
import ash.tools.ListIteratingSystem;

import com.haxepunk.HXP;

import Constants;
import game.component.Positionable;
import game.component.Visible;

import game.node.RenderNode;

class RenderingSystem extends ListIteratingSystem<RenderNode> {

    public function new() {
        super(RenderNode, this.updateNode);
    }

    private function updateNode(node:RenderNode, time:Float) : Void {
        node.renderable.image.render(HXP.buffer, node.position.position, Constants.ORIGIN);
    }
}

有小费吗?

最佳答案

如果在C++中使用缓冲区渲染,则需要在构造函数中设置渲染模式。这是因为Engine构造函数是创建屏幕缓冲区的唯一位置。不幸的是,API文档没有明确解释这一点。

class Main extends Engine
{
    public function new()
    {
        super(0, 0, 60, false, RenderMode.BUFFER);
    }
}

08-04 17:50
查看更多