code OPENFL notes on openfl
|Installation notes
Haxe
http://www.openfl.org/documentation/getting-started/installing-openfl/
haxelib install openfl
haxelib run openfl setup (will also setup hxcpp & lime-tools)
|OSX install
http://brew.sh/
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
https://gist.github.com/cristobal/9909537
brew install haxe
haxelib setup /usr/local/haxe/lib
haxelib install lime
haxelib run lime setup
lime install openfl
haxelib install actuate
haxelib install hxcpp
|Build and Run
lime run ios (will create xcode project and open it)
lime run neko (launch game with neko, on windows)
lime test neko (launch game with neko, on macos)
lime update ios -simulator (will open xcode set to simulator)
|Add libraries
haxelib git
[openfl-simple-particles](https://github.com/underscorediscovery/openfl-simple-particles)
|Basics on synthax
http://www.openfl.org/archive/developer/documentation/actionscript-developers/
|Start new project
https://github.com/openfl/openfl/wiki/2.1.-Create-New-Project
[code]
lime create openfl:project MyProject
[/code]
|Make multitouch work on ios device
You'll need to add those somewhere
[code]
import openfl.ui.Multitouch;
import openfl.ui.MultitouchInputMode;
(...)
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
[/code]
to be able to fire the TouchEvent.TOUCH_BEGIN / TOUCH_MOVE / TOUCH_END events.
|Get Stage dimensions
[code]
Lib.current.stage.stageWidth;
Lib.current.stage.stageHeight;
[/code]
|HTML 5 compatibility
https://muut.com/i/openfl/installation:html5-and-opengl
Adding to the project.xml
[code]
[/code]
|Setup landscape and portrait for mobile
http://www.openfl.org/archive/community/programming-haxe/locking-screen-orientation/
[code]
[/code]
|Working with #if
http://www.openfl.org/forums/#!/programming:is-it-possible-to-read-debu
[code]
#if debug
trace("debug mode");
#else
trace("release mode");
#end
[/code]
|Background color
in your project.xml
[code][/code]
|MouseEvent cast e.target to sprite
https://muut.com/i/openfl/bugs:html5-mouseevent-cant-cas
|Function as parameters
http://www.openfl.org/archive/community/programming-haxe/passing-function-argument/
Simple declaration
[code]
var typeName:Void->Void = test;
public var eventBegin_cb:BitmapData->Bitmap;
public var eventEnd_cb:Sprite->Void;
typeName(); // to run the function
[/code]
An array of function would be
[code]
var arr:ArrayVoid> = new ArrayVoid>();
//even better ArrayVoid> for many function with different return types
[/code]
Using the callback
[code]
i = 1234;
arr[i] = myFunction;
arr[i](); //will run the function;
[/code]
| LINKS
[TileSheet](http://haxecoder.com/post.php?id=21)