1

我已经开始通过这些教程学习 Haxe: https ://www.youtube.com/watch?v=emahgLaCZkc&list=PL4neAtv21WOmmR5mKb7TQvEQHpMh1h0po&index=9

不同的是,对于视频中的示例,我的项目结构为一个 .hx 文件。而且public function new在调试时我什么也做不了。

我究竟做错了什么?

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

            });
        });
    }
}
4

0 回答 0