如何退出Haxe/OpenFL程序? [英] How to exit Haxe/OpenFL program?

查看:119
本文介绍了如何退出Haxe/OpenFL程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Haxe,OpenFL(以前为NME)和HaxeFlixel制作游戏.

I am making a game using Haxe, OpenFL (Formerly NME) and HaxeFlixel.

但是,问题是,我似乎找不到一种制作Flixel按钮的好方法,该按钮在按下时会关闭游戏.我打算在主菜单上创建一个退出"按钮.

However, problem is, I can't seem to find a good way to make a Flixel button that will shutdown the game when pressed. I was planning to make a "quit" button on the main menu.

有没有简单的方法可以做到这一点?

Is there any simple method to do so or is it impossible?

推荐答案

这取决于编译目标:我将假设您要编译为CPP(Windows EXE).在这种情况下,您应该只能使用以下内容:

It depends on the compilation target: I'm going to assume you're compiling to CPP (Windows EXE). In which case you should just be able to use the following:

import flash.system.System; // Or nme.system.System if you're using NME

...

// in your FlxButton callback:
System.exit(0);

我现在无法测试,所以我不知道这会对Flash产生什么影响(即,您可能必须将其包装在cpp的条件编译标志中),但是我知道它无法正常工作对于iOS.

I can't test right now so I don't know what effect this would have in Flash (i.e. you may have to wrap it in a conditional compilation flag for cpp), but I do know that it won't work for iOS.

这篇关于如何退出Haxe/OpenFL程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆