How to exit the Haxe / OpenFL program?

I make a game using Haxe, OpenFL (formerly NME) and HaxeFlixel.

However, the problem is that I can not find a good way to make a Flixel button that will turn off the game when pressed. I planned to make the "Exit" button in the main menu.

Is there an easy way to do this or is it impossible?

+7
source share
1 answer

It depends on the purpose of the compilation: I am going to assume that you are compiling CPP (Windows EXE). In this case, you should simply use the following:

import flash.system.System; // Or nme.system.System if you're using NME ... // in your FlxButton callback: System.exit(0); 

I can’t check right now, so I don’t know what effect this will have on Flash (i.e. you may need to wrap it in a conditional compilation flag for cpp), but I know that it will not work for iOS.

+14
source

Source: https://habr.com/ru/post/948798/


All Articles