@mikekasprzak I must break myself of that habit. "I dunno how to solve this so I guess I'll just wander over here and... oh a funny video.." (Yesterday)

@twobitart something between human and clothing?! (Yesterday)

@joeydehnert I try to do this but it's hard to overcome the dread I'm building about all the rewrites that are waiting for me, haha (Yesterday)

@TyrusPeace hahahah awesome (Yesterday)

@TyrusPeace I find myself doing a lot of style/art/juice/particle stuff whenever I'm stuck on a harder problem somewhere else ;D (Yesterday)

@LyleCox Huh, interesting! Oh yeah, nice meeting you! Always cool to run into internet people in the real world ;D (Yesterday)

@konjak dont wanna get cramps! :3 (Yesterday)

@eigenbom Interesting! I figured it would be something like "the easiest stuff on the to-do list first" (Yesterday)

A lot of artists I know do warm up sketches and thumbnails... do programmers have warm up exercises or is it best to just JUMP RIGHT IN? (Yesterday)

@infinite_ammo is there a poster of Rick Berman (Yesterday)

@psysal so gdlk (2 days ago)

@NoelFB the party never ends noel... it never ends... (2 days ago)

@Zeomne Whoa thanks! :O (2 days ago)

@ADAMATOMIC @theBanov @infinite_ammo hahahahahh #busted (2 days ago)

@infinite_ammo @redlettermedia @ChevyRay @NoelFB WHAAAAAAAAAATT?? (2 days ago)

@BriProv Been using Spine but mostly because they had ready to roll code to drop into my engine to use their animation data. (3 days ago)

@infinite_ammo don't play with my heart (3 days ago)

@BenRuiz on the 420 bloodmoon all of the world money will turn into weed buy your dlc now before it too late (3 days ago)

Why do I get so mad when I see DLC advertisements on the Steam store page of a game that isn't even out yet? (3 days ago)

@kertgartner Just have an annotation link to your current work in the first 10 seconds ;D (3 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