@pietepiet qt pi (Today)

RT @djcoreynolan: Ahh so now I know what @Lumin0via and I would look like if we were assimilated into the @kylepulver universe. <3 t… (2 days ago)

@ComcastMike Oh, no, that would be @goldbuick! (2 days ago)

@chickysprout @dom2d waaaaaa this looks fucking fantastic! STYLIN'~ (2 days ago)

@goldbuick @comcast Yeah it's amazing how progress somehow totally reversed at some point. Bandwidth caps are ancient. (2 days ago)

@goldbuick @comcast Holy shit that's insane. I didn't think companies actually charged for more bandwidth in the US. (2 days ago)

@SteveSwink @MattThorson yooooooooooooooooooooo were you able to fix the shoulder button squish? (2 days ago)

@infinite_ammo David haven't you been watching?! DAVID. (2 days ago)

@ThemsAllTook Auugh I cant stand it. I always feel like I'm the most terrified person on the whole flight. (3 days ago)

Smooth flight: Wow flying is so cool I should do this more. Bumpy flight: FUCK THIS I AM NEVER FLYING AGAIN FUCK (3 days ago)

@notch @TommyRefenes "WOW THIS IS GOING TO BE GREAT I KNOW EXACTLY WHAT TO DO" *sit down at computer* "I have no idea what to do." (4 days ago)

@ChevyRay Silviu Stan strikes again. (4 days ago)

RT @Capy_Nathan: Every year @RichhhardLi puts out beautiful, intense, emotional videos from EVO. This year's is just phenomenal. t.… (4 days ago)

@TommyRefenes YEAH John Hammond was able to place a copyright strike on the painting after google bought it :( (4 days ago)

@Marshall2Re hey thanks! ;D (4 days ago)

Anonymous inside sources confirmed that Google has purchased a pretty cool painting of a Stegosaurus at a yard sale for 0.000000001 billion (4 days ago)

@TommyRefenes dang you got like 9999 pills (5 days ago)

@Livelyivy Oh nooooo I thought we sealed off the murder hole once and for all (5 days ago)

@fncwill I wasn't playing, only saw the screen. (5 days ago)

Nobody is a loser at the Saratoga Casino and Raceway! (You could be a "looser" though.) t.co/b6HOTas7eR (5 days ago)

follow
search

2013 - 4 - 8 / 12:21 pm / tutorials

FlashDevelop with HaXe NME and HaXePunk

FlashDevelop with HaXe NME and HaXePunk

I spent most of yesterday diving into a whole new world of magic and fun: Haxe. I was hesitant at first because I was dreading the whole ordeal of setting up a new development environment, but it turned out to be way more straight forward than most set ups I've experienced.

I ended up getting a quick demo of thousands of entities rotating, scaling, and alpha blending at a steady 50-60fps with the Windows build of HaxePunk, and that has me pretty excited!

Image

Follow along as I take you on a journey of code and game development! (For reference, I'm using Windows 7.)

Before You Start
I'm assuming that you are a flash developer that's using FlashDevelop and you want to migrate to Haxe NME. More specifically, this will be about getting HaxePunk up and running as quickly and as easily as possible. Oh, and I'm also assuming you're using Windows.

Download NME Installer
Go on over to the NME downloads page and download the installer for your OS. For Windows, you want to download this installer.

The NME installer will take care of a lot of stuff for you, and actually we're already almost done after installing just this.

Command Line Setup
After the installer is finished running you'll have to do one more thing to actually finish the set up completely. Open up a command prompt window (if you go to the start menu and just type 'cmd' you'll find it) and type 'nme setup windows' into it.

Image

You'll be presented with a prompt to install Visual Studio C++ Express. Go ahead and do that, as this is necessary for FlashDevelop to build your project to a native windows application.

FlashDevelop Template
Now that NME is installed and the Windows stuff is set up, you'll want to install some FlashDevelop project templates. This enables you to start a new NME project in FlashDevelop when you launch it.

New NME Project
This is where things get a little weird since we're not following the typical HaxePunk install route. We're going to start a new NME project, and then dump HaxePunk into the source folder of that project to use it. There are other ways to do it, but after struggling with some stuff yesterday, this is the best way I could get working for now.

Image

Start a new project in FlashDevelop and choose an NME Project. Click OK to create the project. It generates some default files and folders for you, and we're going to mess with those a little bit now.

HaxePunk Setup
Almost done! Now go download the latest version of HaxePunk from the Git page. Just click on the "ZIP" button to download a zip file of the entire repository. Inside that zip file that you just downloaded there is a "src" folder. Inside that folder is a "com" folder. Take the "com" folder and add it to the "src" folder of the NME project we just created.

Image
You also need to take the contents of the "assets" folder in the HaxePunk zip file and place them in the "assets" folder of your new project.

Image
Hooking up Assets
There's one more important thing that you'll need to change, and that's the "application.nmml" file. For those of you that have worked in AIR, this is somewhat similar to the application.xml file for AIR projects. In the assets section (line 19) you'll need to add some lines for the HaxePunk assets we just added.

I used this file as a guide to figure out what to modify in here. My assets section of my application.nmml ends up looking like this.

A New Main.hx
The final thing that needs to be changed is the Main.hx file in the project. Since HaxePunk works differently than the native Flash style code, we'll need a new Main.hx. Here's the complete code for Main.hx that I based off of this file.

package ;

import com.haxepunk.Engine;
import com.haxepunk.HXP;

class Main extends Engine {
public function new() {
super(640, 480, 60, true);
}
override public function init():Dynamic {
super.init();
HXP.console.enable();
trace("HaxePunk is running!");
}
public static function main() { new Main(); }
}


Now with any luck you should be able to build this project into anything you want! Flash, Windows, HTML5, and more. I haven't done much with Android or iOS building yet, so I'm not really sure what's involved for those... but this should be enough to get you started with HaxePunk with NME.

Pro Tips
There's an option in FlashDevelop that makes autocomplete kinda clunky with Haxe for some reason. To fix this issue, go to Tools -> Project Settings. Go to the "HaxeContext" section, and set "Disable Completion on Demand" to False.

Image

If you have issues compiling to a Windows build, try setting up Visual Studio again with the command line "nme setup windows"

Check out this handy list of AS3 -> HaXe conversions.

Make sure you're using the nme library when importing classes. For example, you want to use "nme.geom.Point" for the Point class and NOT "browser.geom.Point" or any other. FlashDevelop will autocomplete for you alphabetically, so just double check that you're getting the nme versions of things when importing.

Downloads Recap
Download the latest HaxePunk zip.

Download the NME 3.5.5 Windows installer.

Download the verison 4.3.0 of FlashDevelop.

Download the FlashDevelop project templates for HaXe NME.

11 Comments
Avatar

2013 - 4 - 8 2:00 PM

Feyfausto

and a tutorial how can we conver a FlashPunk project for Haxepunk? :3

Avatar

2013 - 4 - 11 12:47 PM

ratking

I guess the struggles you experienced are related to my own? See here: http://forum.haxepunk.com/index.php?topic=342.0

Avatar

2013 - 4 - 12 1:39 AM

Kyle

Actually strangely enough I didn't encounter that specific problem. I actually just wanted direct access to the HaxePunk source inside my project rather than having it live in the Haxelib folder in a faraway place.

I'm actually putting Haxepunk down for now because it has a lot of shortcomings that I didn't notice when I first started experimenting with it. It's a bummer because I'm really excited about the prospect of better performing games on Win/Mac/Linux, but it's just not polished enough for a big game project.

Avatar

2013 - 4 - 29 3:35 PM

Makai

Are these shortcomings related to HaxePunk's base in FlashPunk or are they issues with HaxePunk itself?

Care to elaborate a bit more on this?

Avatar

2013 - 5 - 3 3:45 PM

Kyle

The short comings are with HaxePunk itself. I love FlashPunk and if I could use it forever, I would. HaxePunk is missing some of the core functionality of drawing (right now at least) that I use a lot in FlashPunk. Stuff like drawing lines, circles, rectangles, manipulating bitmapdata and using it for image rendering, and certain image features like sprite.flipped are broken or not yet implemented for native targets. I believe it's also not ported with the latest version of FlashPunk in mind (which is maintained by Draknek and not Chevy Ray anymore)

If there was a complete copy of FlashPunk as it stands right now with way better performance and compilation to native targets then I would be all over it. HaxePunk is close, but it's not there yet for my needs unfortunately.

Avatar

2013 - 9 - 30 9:05 AM

salaniojr

Hi Kyle,

I've been researching the avaiable options in Haxe and, as you pointed out, it seems that they lack some maturity. The one ahead is HaxeFlixel in community activity, commits and docs. It can be a good start.
Out of curiosity... are you still using Haxe? If you do, what are you going for? Creating your own framework?

Thanks

Avatar

2013 - 9 - 30 3:35 PM

Kyle

Hey! I am not working in Haxe anymore. I called it quits on Haxe after I realized that a lot of basic functionality that I was used to was not present yet in HaxePunk. I did look into HaxeFlixel a little bit, but after some more experimentation I landed on C# and SFML which I'm currently using to build a framework.

Avatar

2014 - 2 - 9 3:31 PM

Andre

Are you able to provide the source code for the test app in the post? The one with a lot of rectangles

Avatar

2014 - 2 - 10 12:02 AM

Kyle

Unfortunately it's been a long time since I've used Haxe, and I don't have the source for that test application anymore.

Avatar

2014 - 2 - 10 8:16 AM

Andre

Can you remember how you drew the squares and rotated them? Was it an HaxePunk API or AS3 directly?

Avatar

2014 - 2 - 10 12:00 PM

Kyle

I'm pretty sure I just made a square graphic and used HaxePunk to create thousands of them. When they were created they would get a random color and alpha and scale, and during their update they would rotate.

Avatar

Post your comment!

POST COMMENT

about

About

Hi there, my name is Kyle, and I'm a 27 year old kid with adult powers. I'm making video games and living the indie game developer life in Tempe, Arizona. Here you will find my thoughts, games, websites, doodles, and other stuff like that. I worked on Snapshot, Offspring Fling, and a whole bunch of other games. I also created and maintain Otter, a 2d game making framework. If you want to get a hold of me use the form on the bottom of the page, leave a comment, or just tweet at me. I try to post three times a week. Thanks for stoppin' by! You're the coolest.

facebook

videos

Do you want to make a Let's Play of one of my games, or a just a video featuring footage of my games? You have my full permission to do so! Even if you are monetizing your videos, you still have my full permission to use any footage from any of my games. Go for it!

contact

Your message has been sent! Thanks :)
SEND MESSAGE