I can't get the following to work in Android (Java), even though it runs perfectly in HTML5-Debug:
package;
import kha.Assets;
import kha.Framebuffer;
import kha.Scheduler;
import kha.System;
import kha.Color;
import kha.input.Keyboard;
import kha.input.KeyCode;
import kha.input.Surface;
class Main
{
private static var fntX:Int;
private static var fntY:Int;
public static function onUpdate():Void
{
}
public static function onRender(frames:Array<Framebuffer>):Void
{
var g2 = frames[0].g2;
g2.begin();
g2.color = Color.Magenta;
g2.font = Assets.fonts.KingthingsOrganica; // Insert your favourite font here!
g2.drawString("Test!", fntX, fntY);
g2.end();
}
public static function onKeyDown(key:KeyCode):Void
{
}
public static function onKeyUp(key:KeyCode):Void
{
if(key == KeyCode.Back || key == KeyCode.Escape)
System.stop();
}
public static function onTouchStart(index:Int, x:Int, y:Int):Void
{
fntX = x;
fntY = y;
}
public static function onTouchEnd(index:Int, x:Int, y:Int):Void
{
}
public static function onTouchMove(index:Int, x:Int, y:Int):Void
{
}
public static function main()
{
System.start({title: "Project", width: 1024, height: 768}, function(_)
{
// Just loading everything is ok for small projects
Assets.loadEverything(function()
{
// Avoid passing update/render directly,
// so replacing them via code injection works
Scheduler.addTimeTask(function() { onUpdate(); }, 0, 1 / 60);
System.notifyOnFrames(function(frames) { onRender(frames); });
if(Keyboard.get() != null)
Keyboard.get().notify(onKeyDown, onKeyUp);
if(Surface.get() != null)
Surface.get().notify(onTouchStart, onTouchEnd, onTouchMove);
});
});
}
}
I tried drawing images, besides drawing text, but also without success. The display just remains black, even when I do a clear to another colour. What am I doing wrong?