Haxe, call new function

101 views Asked by At

I've started learning Haxe with these tutorials: https://www.youtube.com/watch?v=emahgLaCZkc&list=PL4neAtv21WOmmR5mKb7TQvEQHpMh1h0po&index=9

Differently, to the example in the video, I have my project structured to one .hx file. And I can't make public function new to do anything while debugging.

what am I doing wrong?

package;

import kha.Assets;
import kha.Sound;
import kha.audio1.Audio;
import kha.audio1.AudioChannel;
import kha.Framebuffer;
import kha.Scheduler;
import kha.System;

class Main {
    var sound:Sound;
    var audioChannel:AudioChannel;

    public function new () {
            sound = Assets.sounds.tone;
            audioChannel = Audio.play(sound, true);
            trace('Hello world test');
    }

    static function update(): Void {
    }

    static function render(frames: Array<Framebuffer>): 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 () { update(); }, 0, 1 / 60);
                System.notifyOnFrames(function (frames) { render(frames); });   

            });
        });
    }
}
0

There are 0 answers