haXe Forum > haxe.Timer in C++
-
Paul Milham Mar 04 at 00:19
I'm trying to get haxe.Timer to work in C++, but I'm having some trouble. I made a simple class to test with.
package; import haxe.Timer; class CPPTimer { private var _appTimer:Timer; public function new() { _appTimer = new Timer(300); _appTimer.run = function():Void { trace("called!"); }; } static function main():Void { new CPPTimer(); } }
This code doesn't seem to work when compiled as C++ when I run the executable. The program ends run after it starts and doesn't trace anything out. However, this same code works fine when compiled as a swf. Am I missing something specific that needs to happen when targeting C++? -
Andy Li Mar 04 at 08:47
Maybe because c++ programs will exit right after everything in main() is executed, unlike Flash exit only if you closed the window. So what you can try is to add the follow at the end of main():
while (true){}
-
Philipp Klose Mar 04 at 16:32
Maybe its better to use
cpp.Sys.sleep(a_few_milliseconds)within the loop to keep cpu consumption lower. -
George Mar 19 at 15:06
I believe I've had a similar issue a while back, I'm fairly sure I solved it by using the neash class for the timer, they seem to operate the same so all you'll need to do is replace with
import neash.Timer;
< Prev
| Page 1 / 1 |
Next >