Permalink
Browse files

Added ability to instantiate custom Stage classes using Lib.create

  • Loading branch information...
1 parent c38efc9 commit fa6c6587ae867b43dbec6e0b9f2eb2af2c0bcb24 @jgranick jgranick committed Mar 28, 2013
Showing with 7 additions and 4 deletions.
  1. +5 −2 native/Lib.hx
  2. +2 −2 nme/Lib.hx
View
@@ -56,7 +56,7 @@ class Lib
close();
}
- public static function create(inOnLoaded:Void->Void, inWidth:Int, inHeight:Int, inFrameRate:Float = 60.0, inColour:Int = 0xffffff, inFlags:Int = 0x0f, inTitle:String = "NME", ?inIcon:BitmapData)
+ public static function create(inOnLoaded:Void->Void, inWidth:Int, inHeight:Int, inFrameRate:Float = 60.0, inColour:Int = 0xffffff, inFlags:Int = 0x0f, inTitle:String = "NME", ?inIcon:BitmapData, ?inStageClass:Class<native.display.Stage>)
{
if (sIsInit)
{
@@ -72,6 +72,9 @@ class Lib
sIsInit = true;
initWidth = inWidth;
initHeight = inHeight;
+
+ var stageClass = inStageClass;
+ if (stageClass == null) stageClass = Stage;
var create_main_frame = Loader.load("nme_create_main_frame", -1);
@@ -81,7 +84,7 @@ class Lib
nmeMainFrame = inFrameHandle;
var stage_handle = nme_get_frame_stage(nmeMainFrame);
- Lib.nmeStage = new Stage(stage_handle, inWidth, inHeight);
+ Lib.nmeStage = Type.createInstance (stageClass, [stage_handle, inWidth, inHeight]);
Lib.nmeStage.frameRate = inFrameRate;
Lib.nmeStage.opaqueBackground = inColour;
Lib.nmeStage.onQuit = close;
View
@@ -89,11 +89,11 @@ class Lib
* @param title The title to use when creating the application window.
* @param icon An icon to use for the created application window.
*/
- public static function create(onLoaded:Void->Void, width:Int, height:Int, frameRate:Float = 60.0, color:Int = 0xffffff, flags:Int = 0x0f, title:String = "NME", icon:BitmapData = null):Void
+ public static function create(onLoaded:Void->Void, width:Int, height:Int, frameRate:Float = 60.0, color:Int = 0xffffff, flags:Int = 0x0f, title:String = "NME", icon:BitmapData = null, stageClass:Class<Stage> = null):Void
{
#if display
#elseif (cpp || neko)
- native.Lib.create(onLoaded, width, height, frameRate, color, flags, title, icon);
+ native.Lib.create(onLoaded, width, height, frameRate, color, flags, title, icon, stageClass);
#end
}

0 comments on commit fa6c658

Please sign in to comment.