Frage

So I'm making a game with Haxe and Haxepunk. Fine. Except that when I export to C++, nothing is rendering! I posted this previously on the Haxepunk boards, so more info can be found here. Here's an excerpt from the Haxepunk thread;

I can still compile it just fine, but nothing in the game is actually rendering except for the background color I defined. The console still works and renders fine, though. The HaxePunk console tells me Atlases using BitmapData will not be managed.

I'm using Ash's component-entity system, and I'm not using Haxe's Entities. The relevant objects have a Visible component attached to them, which looks like this;

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);
    }
}

And this is the associated rendering system;

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);
    }
}

Any tips?

War es hilfreich?

Lösung

If you are using buffer rendering in C++ you'll need to set the render mode inside the constructor. This is because the Engine constructor is the only place a screen buffer is created. Unfortunately the API docs don't clearly explain this.

class Main extends Engine
{
    public function new()
    {
        super(0, 0, 60, false, RenderMode.BUFFER);
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top