All Projects → haxeui → haxeui-kha

haxeui / haxeui-kha

Licence: MIT license
The Kha backend of the HaxeUI framework -

Programming Languages

haxe
709 projects

Projects that are alternatives of or similar to haxeui-kha

clay
Cross-platform 2d game framework
Stars: ✭ 39 (+2.63%)
Mutual labels:  kha
aura
A fast and lightweight 3D audio engine for Kha.
Stars: ✭ 31 (-18.42%)
Mutual labels:  kha
haxeui-hxwidgets
The hxWidgets backend of the HaxeUI framework -
Stars: ✭ 20 (-47.37%)
Mutual labels:  haxeui-backend
khm.imgui
Imgui core for Kha
Stars: ✭ 16 (-57.89%)
Mutual labels:  kha
Twinspire
Twinspire is a Kha-based game engine using Haxe.
Stars: ✭ 12 (-68.42%)
Mutual labels:  kha
Kha2DRaycasting
2D raycasting in kha
Stars: ✭ 12 (-68.42%)
Mutual labels:  kha
kha-tutorial-series
source code from kha tutorial series
Stars: ✭ 56 (+47.37%)
Mutual labels:  kha
sparkler
Modular Macro-powered Particle System for haxe
Stars: ✭ 16 (-57.89%)
Mutual labels:  kha
haxeui-openfl
The OpenFL backend of the HaxeUI framework -
Stars: ✭ 35 (-7.89%)
Mutual labels:  haxeui-backend

build status

haxeui-kha

This is the Kha backend for HaxeUI

Installation

  • haxeui-kha has a dependency to haxeui-core, and so that too must be installed
  • haxeui-kha also has a dependency to Kha, please refer to the installation instructions on their site
mkdir Libraries
cd Libraries
git clone https://github.com/haxeui/haxeui-core.git
git clone https://github.com/haxeui/haxeui-kha.git
git clone https://github.com/haxefoundation/hscript.git

Or even better, add them as git submodules for proper versioning!

Usage

The simplest method to create a new Kha application that is HaxeUI ready is to use one of the haxeui-templates. These templates will allow you to start a new project rapidly with HaxeUI support baked in.

If however you already have an existing application, then incorporating HaxeUI into that application is straightforward.

khamake.js

Simply add the following lines to your khamake.js and rebuild your project files:

project.addLibrary('haxeui-core');
project.addLibrary('haxeui-kha');
project.addLibrary('hscript');

Toolkit initialisation and usage

The Kha system itself must be initialised and a render loop started. This can be done by using code similar to:

class Main {
    public static function main() {
        kha.System.start({}, function ( _ ) {
            kha.Assets.loadEverything(function() {
                haxe.ui.Toolkit.init();

                final screen = haxe.ui.core.Screen.instance;
                final ui = haxe.ui.macros.ComponentMacros.buildComponent("ui.xml");

                screen.addComponent(ui);

                kha.System.notifyOnFrames(function( framebuffers: Array<kha.Framebuffer> ) {
                    final fb = framebuffers[0];
                    final g2 = fb.g2;
                    g2.begin(true, kha.Color.White);
                        screen.renderTo(g2);
                    g2.end();
                });
            });
        });
    }
}

Once the toolkit is initialised you can add components using the methods specified here.

Kha specifics

As well as using the generic Screen.instance.addComponent, it is also possible to render a component to a specific surface use the components special renderTo function. Eg:

main.renderTo(...);

Addtional resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].