I am making a game using Haxe, OpenFL (Formerly NME) and HaxeFlixel.
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?
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);
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.
Related
Good evening,
I inherited a project made using QT creator (C++ and Qt Quick).
The target is a DaVinci DM8168 board with **Linux kernel 2.6.37 **on it.
In particular I'm using Qt Creator 4.2.0 (4.2.0)
Based on Qt 5.7.1 (GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 64 bit)
I can build & run the application for the target and I can see it running.
I need to launch the profiler. But it does not work. When i run the application (on the target) using the parameter:
qmljsdebugger=port:xxxx
then the application does not start anymore!
I tried to add these options to the project's .pro file:
DEFINES '' += QMLJSDEBUGGER
DEFINES '' += QT_DECLARATIVE_DEBUG
PACKAGECONFIG_append = " qml-debug"
I, obviously, build in debug mode.
When I try to run the applicative on the target i get this message:
QML debugging is enabled. Only use this in a safe environment. Process
killed by signal
I repeat: if the option "qmljsdebugger=port:xxxx" is removed then the application starts and works properly.. but of course the profiler wouldn't connect in this case.
As I said, I've inherited the project and I'm complete new to this environment.
Any help or suggestion?
update
these are now the lines I've added to the .pro file
DEFINES '' += QMLJSDEBUGGER
DEFINES '' += QT_QML_DEBUG
CONFIG += qml_debug
I checked the various path for QT and exported PATH and LD_LIBRARY_PATH.
Unfortunately nothing changes:
If I launch my program using:
/opt/MyPrefix/MyProgram -platform eglfs
then it works.
if I use:
/opt/MyPrefix/MyProgram -qmljsdebugger=port:3456 -platform eglfs
then it crashes
QML debugging is enabled. Only use this in a safe environment.
Segmentation fault
the program seems to start in Debug Mode and this is ok. The problem is the profiler :(
ps: As far as I know there are no firewalls running on the target. I'll check better for sure.
update 2
I tryed the same solutions as above but on a simple program as suggested(an "hello world" basically) and it does not crash when the "-qmljsdebugger=port:3456" option is specified... I really don't know what the problem is in my original application.
First there are a few prerequisites to make qml debug run like being sure that Qt was built with the exact same toolchain as the binary. You should take a look at Qt Wiki: https://wiki.qt.io/How_To_Profile_QML_App_on_Embedded_Device
An important note is that how you make qml debugging works has changed between Qt Quick 1 and Qt Quick 2. As you are using Qt 5, I believe you should be using Qt Quick 2. So that means that you should not use QT_DECLARATIVE_DEBUG, but QT_QML_DEBUG.
More details: https://doc.qt.io/qt-5/qtquick-debugging.html#qml-debugging-infrastructure
If you still have issue after using the proper DEFINES and making sure that evry prerequisite was met, then you should try with a basic Qt program that does nothing, but display a simple QML item (like a Rectangle or a Button) ans see if you still have the issue.
this is somenthing I was trying to solve for HOURS, but I don't get why this is not working.
First of all, I'm trying to do a release for neko or windows in Flash Develop. My project is a OpenFl one, and the language is Haxe 3.
What I have installed:
actuate: [1.8.6]
flixel-addons: [2.3.0]
flixel: [4.2.1]
hxcpp: [3.4.64]
lime: [2.9.1]
nape: [2.0.20]
openfl: [3.6.1]
And yes; I'm using haxeFlixel.
When I try to do a release in windows or neko, these errors appear:
-E:/HaxeToolkit/haxe/lib/openfl/3,6,1/openfl/_internal/renderer/opengl/utils/SpriteBatch.hx:12: characters 7-28 : Module openfl.display.Shader does not define type Shader
-E:/HaxeToolkit/haxe/lib/openfl/3,6,1/openfl/_internal/renderer/opengl/utils/SpriteBatch.hx:12: characters 7-28 : For function argument 'ax'
-src/skill/SkillLogicProjectil.hx:13: lines 13-54 : Defined in this class
-E:/HaxeToolkit/haxe/lib/openfl/3,6,1/openfl/_internal/renderer/opengl/shaders2/Shader.hx:11: characters 7-28 : Module openfl.display.Shader does not define type Shader
The most funny thing is: I'm not even using Shader in SkillLogicProjectil. That class only creates a sprite that follows a Player and has a var with the sprite that represents the skill.
If I comment this class, the error is in another class, and finally ends in my GameState.
This error doesn't appear when I do a release in html5. In html5 there are no problems with the release, but I canĀ“t make the game load without Flash Develop running the process in http://localhost:2000/. I need to make a release that can be opened with a computer, without using Flash Develop to open it.
What can I do?.
The new version of Flixel supports Haxe 3.4.3 and OpenFL 8, have you given these versions a try?
I'm trying to get the PCL Visualizer demo examples to work (all code here: http://pointclouds.org/documentation/tutorials/pcl_visualizer.php) for Windows, PCL 1.6, 32 bits version.
It works fine except for the Interaction Customization part, which is ironically the one i'm most interested on. An unhandled exception occurs at the spinOnce(100) line on the main method. From the long search I've done, it looks like it is deeply connected to VTK not being thread safe and keyboard/mouse callbacks interfering with the VTK window. However, I don't think I've completely understood this and could be mistaken. I have found a very similar question here in stackoverflow (using "pcl::visualization" in different threads from different instance of a class) and I tried using scoped_locks around the spinonce, as he suggests, but I think I'm not doing it right.
Has anyone managed to fully use this example on win32? For reference, here is my poor attempt at locking the spinonce:
while (!viewer->wasStopped ())
{
boost::mutex vis_mutex; //storage for static lock
boost::mutex::scoped_lock lock(vis_mutex);
viewer->spinOnce ();
boost::this_thread::sleep (boost::posix_time::microseconds (100000));
}
Thanks in advance!
I am afraid that it may be related to the version of PCL.
Tutorials are made to match latest versions of PCL and since 1.6 things might have changed.
I recommend you to update to the latest PCL from github. (actually I use code from this tutorial on win64 right out of the box, no issues)
I am trying to write some cross-language code with Haxe/OpenFL and compile it using FalshDevelop. But I get an error as soon as I use the basic Sys.print function. A minimal example is as follows:
package;
import flash.display.Sprite;
class Graphic extends Sprite {
public function new () {
super ();
}
static function main() { //used in standalone swf project
Sys.print("Hi");
}
}
It turns out that the default compile command of FlashDevelop is something like:
haxelib run openfl build project.xml flash
,which gives an error on Sys.print:
Graphic.hx:xx: characters 2-11 : Accessing this field requires a system platform
(php,neko,cpp,etc.)
My guess is that Sys.print isn't available in the flash target or flash isn't a system platform (strange). I was wondering if there is way to work around this, and configure FlashDevelop so that the compile command is:
haxelib run openfl build project.xml neko
Thanks
There are actually 2 questions.
For the first one, Sys.print is available only on some platforms because it wouldn't make sense in others(what would it do in flash?), what you probably want is trace, which is used to print things for debug purposes.
For the second question there is a drop down menu at the top of flashdevelop if you created a openfl project that looks like this and does exactly that:
I developed an application using a recent Glade, so I need it to load the UI from XML at runtime, using the GtkBuilder. If I try to run this on a distro which has too old a Gtk (e.g. RHEL 5), it will fail like this
undefined symbol: gtk_builder_new
which is normal and expected. But I wonder if there is a way to catch that error and instead display a GUI error dialog saying something like "your version of Gtk is not new enough"? This is an error that happens before my main() starts, so really the question is, is there a way to handle runtime linking errors? While googling, I found a mention of the concept of a linker plugin but I didn't find details about that yet. It sounds like something which would have to exist outside my application anyway, so maybe that's going a bit far.
I could use dlopen() to load Gtk, but that's ridiculous because I'd have to give the full path to it, and then I'd have to call dlsym() a lot to link every function that I need. ld-linux.so does the search for me. Is there a way I can use ld-linux.so to tell me the path to libgtk without actually loading it, then I check whether the version is new enough (or just whether gtk_builder_new exists), then finish the runtime linking if it's OK?
Well, it doesn't work that way on a Linux distro. What you're basically doing is bypassing the package manager.
The good way is to build your software on the target distro. At configuration time (call to ./configure) you will see that the requirements to use your software are not met. Or if you have no configure script, the compiler will yell at link time.
Then, it's the packager's job to fill in the requirement of the package. If in the .spec file of your RPM package you require gtk >= 2.16, then at installation time, the user will be shown the dialog telling him that some dependencies are missing, and he will see that his GTK version is too old.
You seem to be talking about the situation where you have compiled against headers with a recent enough version, but are running on a system where your library is not recent enough.
GTK provides a facility for checking that you have linked against a new enough version of the library. For example, if you need at least GTK 2.12 (which is the version in which GtkBuilder was introduced) you can use this code which will even display a nice GUI error dialog:
if (gtk_major_version < 2 || gtk_minor_version < 12) {
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"Your version of GTK is too old to run this program.");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"You need at least version 2.12.0; your version is %d.%d.%d.",
gtk_major_version, gtk_minor_version, gtk_micro_version);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
exit(-1);
}
Here is a workaround which might help: Rename your exe and create a bash script which calls it.
Now you can do this:
EXE=...name-of-your-real-executable...
LOG=logfile
$EXE > "$LOG" 2>&1 || {
if grep "undefined symbol: gtk_builder_new" "$LOG" ; then
... show error message ...
fi
}
[EDIT] Alternatively, you can create a really small test program which just contains a call to gtk_builder_new and run that during installation or in the test script.
That way, you don't need to check for a specific error message (which might get translated on non-English systems). If this small test program fails, you can be sure it's because of this missing symbol and nothing else.