View unanswered posts | View active topics



Reply to topic  [ 3 posts ] 
Haxe NME template improvements 
Author Message
Member

Joined: Mon Sep 20, 2010 8:55 am
Posts: 92
Reply with quote
Hello.

I've made some improvements to default NME template:
- You no longer get blank screen upon compilation - a red circle is drawn.
- Main class is inherited from Sprite, just like in Flash template.
- Flash debugger is enabled by default in NMML.

These are the things I spent some time to figure after creating my first NME project.

I can't attach patch, so here's the code:

Code:
Index: FlashDevelop/Bin/Debug/Projects/370 HaXe - NME Project/application.nmml.template
===================================================================
--- FlashDevelop/Bin/Debug/Projects/370 HaXe - NME Project/application.nmml.template   (revision 2282)
+++ FlashDevelop/Bin/Debug/Projects/370 HaXe - NME Project/application.nmml.template   (working copy)
@@ -4,6 +4,9 @@
    <app file="$(ProjectID)" title="$(ProjectName)" main="$(PackageDot)Main" package="$(PackageName)"
       version="1.0.0" company="$(DefaultUser)" />
       
+   <!-- enable flash debugger -->
+   <haxedef name="fdb" if="target_flash"/>
+   
    <!-- output -->
    <window width="800" height="480" fps="60" background="0xFFFFFF" orientation="landscape" resizable="true" />
    <set name="BUILD_DIR" value="bin" />
Index: FlashDevelop/Bin/Debug/Projects/370 HaXe - NME Project/src/$(PackagePath)/Main.hx.template
===================================================================
--- FlashDevelop/Bin/Debug/Projects/370 HaXe - NME Project/src/$(PackagePath)/Main.hx.template   (revision 2282)
+++ FlashDevelop/Bin/Debug/Projects/370 HaXe - NME Project/src/$(PackagePath)/Main.hx.template   (working copy)
@@ -1,5 +1,6 @@
 package $(PackageName);
 
+import nme.display.Sprite;
 import nme.display.StageAlign;
 import nme.display.StageScaleMode;
 import nme.Lib;
@@ -9,13 +10,27 @@
 $(CBI)* @author $(DefaultUser)
 $(CBI)*/
 
-class Main $(CSLB){
+class Main extends Sprite $(CSLB){
    
+   public function new() $(CSLB){
+      super();
+      initialize();
+   }
+   
+   private function initialize() $(CSLB){
+      var s:Sprite = new Sprite();
+      s.graphics.beginFill(0xff0000);
+      s.graphics.drawCircle(35, 35, 15);
+      s.graphics.endFill();
+      addChild(s);
+   }
+   
    static public function main() $(CSLB){
       var stage = Lib.current.stage;
       stage.scaleMode = StageScaleMode.NO_SCALE;
       stage.align = StageAlign.TOP_LEFT;
       // entry point
+      stage.addChild(new Main());
    }
    
 }
\ No newline at end of file


Mon May 14, 2012 3:54 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
Good suggestion, now improved in SVN.


Tue May 15, 2012 2:16 pm
Profile WWW
Member

Joined: Mon Sep 20, 2010 8:55 am
Posts: 92
Reply with quote
Great, thank you.


Tue May 15, 2012 2:34 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.