Getting started with HaxeFlixel

With Haxe gaining so much popularity, flash work declining and my want to make 2d games with a language I’m already fairly familiar with that I can publish to multiple platforms, I’ve decided that Haxe is the right move. With that decision I had to pick a game engine and it was really between Flambe or HaxeFlixel.

Since I don’t care about a html5 target and I feel slightly more comfortable in the HaxeFlixel API, I have decided to use it.

Getting started is actually pretty easy but there were a few points that tripped me up slightly. The official documentation for installation is actually spot on. Check it out here.

Once installed, you need some more of editor/IDE. Since I’m developing on a Mac, I have pretty limited options. Since the IntelliJ plugin is wonky at best, I’ve gone with Sublime Text.  When setting up Sublime I was easily able to set up the plugin following the instructions but could not for the life of me get it to actually get it to highlight or code complete.

The issue was the instructions I was following didn’t point out the need to set up some path variables.  The easiest way to do this is to add these variables to your .bashrc

In your home directory (~/) run nano .bashrc . If you have this file it’ll open it, if not it will create it. Then add this:

export haxe_path="/usr/bin/haxe"
export HAXE_LIBRARY_PATH="/usr/local/lib/haxe/std:."

Exit and save.

Once you have all your libs set up for HaxeFlixel you want to add a symlink to the subl command in Sublime. This will allow HaxeFlixel to open the project for you when creating new projects.  There are official instructions on this but it didn’t work for me.  My path was slightly different :

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin/subl

And that there covers the initial setup issues I encountered. I’ll likely post more findings as I learn more of HaxeFlixel. I actually never used Flixel before, but have several years of Flash development behind so most of my findings will likely be differences from Flash to Haxe .

StalkCoin

Lately I’ve been doing a lot of Objective-C development for mobile and also took interest in AltCoins (BitCoin, LiteCoin, etc). After google’ing around for about 15 seconds I couldn’t find a menu ticker to show me the current prices of the coins I’m interested in.

So I said screw it and made one.  This was my first attempt at making a native desktop app.

If you’ve ever have done mobile ObjectiveC dev, there is very little difference. The biggest difference is the change in class prefix; UI on iOS, NS on OSX.

Other then that, it’s business as usual. Installed my libs through cocoapods, and  using xibs for layouts/popups.

The most interesting challenge I’ve encountered so far is not directly related to the app, but a language oddity. Coming from AS3 and C#, I use a lot of events. Events in ObjC, Notifications, are not nice. At least this is what my reading has told me. They message all living objects which can be heavy. StalkCoin though is not a large app, but I don’t like the idea of using them.

An alternative is to use delegates or blocks.  And I use this approach a lot in my other apps, but it still doesn’t sit right with me. What I really want is something like as3-signals.  Or C#Messenger. Perhaps I should bite the bullet and port one of this libraries to ObjectiveC.

Any who, it’s available for download now! You can grab it from the here: http://www.openbracket.ca/stalkcoin/

As I work on it I’ll delve more into what I like/dislike and whatever else is interesting.

AppCode

If you have ever done flash development, you quickly realize that the Flash IDE is the worse play to actually write code. It’s down right awful. So you look at other IDEs; FlashDevelop, FlashBuilder, FDT, IntelliJ. If you are like me you would likely have settled on IntelliJ. The team at Jetbrains just get it. The tools is just brilliant from it’s svn/git integration to it colours to it’s epic refactor tools.

Well when I started doing more ObjectiveC development, I started to encounter issues with Xcode that bothered me greatly. Refactor was poor, version control integration was poor, the way it handled opening files frustrated me. Luckily, the Jetbrains team had developed an app that fixes all of these issues for me: AppCode.

Now AppCode isn’t perfect. It lacks the ability to handle xibs and xcdatamodels as well has some of the finer project settings (They actually may be there but if they are they are incredibly difficult to find and access). But despite these short comings this IDE is the bee’s knee’s. Fast, pretty, great refactor,  great app analysis and many more.  For me the price of having to open Xcode once or twice a day is completely worth the benefits that AppCode provides. Mind you, I  work on apps/games that don’t rely heavily on using xibs so I almost never have the need to open Xcode for that. But on the few projects I’ve done that heavily use xibs, I open Xcode, lay them out, hook up my outlets and then switch over to AppCode for everything else.

So if you develop ObjC and haven’t tried this I strongly suggest you download the trial and give it a goal. You’ll likely be hooked before the 30 days are up.

DISCLAIMER: I have no association with Jetbrains. I just love their software and think you should too

StrangeIoC

Moving from Actionscript to Unity one of the things I missed the most was a framework like Robotlegs that has been the base for any as3 project I’ve done in the last year or two. Recently a buddy at work discovered StrangeIoC and I must say, it is awesome.  If you haven’t used and IoC framework before you should really check it out.

Anyways, if you are familiar with Robotlegs then this is definitely for you since the API is very similar. So similar in fact that a guide for RL users exists!

Give it a shot. It’s bloody awesome

XCode shortcuts

Since I’ve been doing a bit of ObjectiveC lately I’ve been stuck in XCode and coming from better IDEs (IntelliJ; and yes I know about AppCode but I don’t have a license) I’ve become very accustomed to a certain workflow that I’ve had difficulty reproducing.

But recently I took some time and found a few of the shortcuts that I *need* which decrease my reliance on my mouse

 

  • Quick Open: cmd+shift+o
  • Jump to: cmd+ctrl+click
  • Jump to in new tab: cmd+alt+click
  • Switch tabs: cmd+shift+ { or }
  • Global Find: cmd+shift+f

 

Still haven’t found a shortcut for quick refactoring so if you know of one please share.

 

NME error – Missing super constructor call

So since my memory sucks and I likely will forget this one, I’m going to put it here. It’s an easy enough fix and a stupid error on my part but it took me a good 30 minutes to figure it out.

On compile after creating an empty project I received this error

Source/Main.hx:15: lines 15-35 : Missing super constructor call

The solution is to add super() to your new function for your class.

Unity development – 3rd party tools I couldn’t live without

For the last few months, I have primarily been doing only Unity work and have come to rely on a few third party tools every day:

RageSpline

http://ragespline.com/

  • Generate 2D vector graphics inside Unity Editor with bézier splines
  • Fully adjustable colors and gradients + emboss styling
  • Multi-texturing with easy texture positioning
  • Automatic physics collider generation with BoxCollider and MeshCollider options
  • Adjustable vertex count for visuals and physics.
  • Grid & snapping gizmo for accurate drawing
  • Good peformance on iOS/Android
  • RageSpline API for run-time code access

2dToolKit

http://www.unikronsoftware.com/2dtoolkit/

2D Toolkit provides an efficient and flexible 2D sprite and text system which integrates seamlessly into the Unity environment. Our key focus with this product is mobile performance and workflow efficiency.

2D Toolkit is designed for rapid prototyping, and is built to take you all the way to a shipping game.

NGUI

http://www.tasharen.com/?page_id=140

NGUI is a powerful UI system and event notification framework for Unity (both Pro and Free) written in C# that closely follows the KISS principle. It features clean code and simple, minimalistic approach to everything. Most classes are kept under 200 lines of code. For a programmer this means a much easier time when it comes to working with the kit — from extending its functionality to tweaking the existing one. For everyone else this means better performance, less frustration, and more fun.

Bonus! Playmaker

http://www.hutonggames.com/

This is possibly the most powerful tool I have used to date in Unity, but I haven’t been able to explore it as fully I would like to. In short, it’s a FSM that can easily hook into all aspects of your application. It allows the developer to quickly and visually create easy light switches to complex AI.

JSONFX and Unity

Hey all. It’s been fucking ages since my last post, but maybe this time I’ll be able to keep this sucker going. But to hell with excuses and whatnot. On to the point!

Recently I have been working with unity to build some games at work and decided to take a crack at a 2d game for myself. One of the first things I’ve decided to do is work on the quest engine for the game. Since this is going to be a single player game I’m storing my quests in a local file. I initially tried to store this data in XML until I discovered how awful XML is in C#. I then moved over to storing my quests in JSON. After some googling I came across JsonFX and went with it since it will also work on mobile.

Looking at the examples it seem pretty straight forward so off I went. And after a little trial and error I got it at least loading and parsing the json into my unity project finally!

using UnityEngine;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Text;
using JsonFx.Json;

public class FetchQuest{
	public string name;
	public int questId;
}

public class StoryQuest{
	public string name;
	public int npcId;
}

public class Quest2{
	public FetchQuest[] fetchquests;
	public StoryQuest[] storyquests;
}

public class QuestManager : MonoBehaviour {
	void Start () {
		StreamReader r = File.OpenText(Application.dataPath+"/quest.json");
	    string _info = r.ReadToEnd();
	    r.Close();
		print(_info);
		var search = JsonReader.Deserialize<Quest2>(_info);
		print(search.fetchquests[0].name);
	}
}

{
"fetchquests":
	[{"name":"test", "questId":1},
	{"name":"test", "questId":1}]
,"storyquests":
	[{"name":"story 1", "npcId":1},
	{"name":"story 2", "npcId":2}]
}

And thats loading and deserializing! This makes me happy. A thing to note and this is what caught me, is that it looks up the class variables by name, so case matters! Remember this!

What is the best way to achieve a Flash/Unity app with shared Nodejs server?

Over the last week or so I have been looking into creating a shared nodejs server that has flash and unity interfaces. I’m still rather new to nodejs so this is a post to ask a question; I’m considering creating a JS file that flash and unity communicate to using external interface calls instead of putting the communication layer inside of the application.

My question is, is this an acceptable approach? One of the reasons I’m considering this is because it seems to be a pain in the ass in Unity to achieve this.

Let me know what you guys think!

I'm an awful blogger yes… But I'm back!?

Hey ya’ll! I know it’s been a long time since I’ve posted, but I’m hoping to get back into the groove. With a recent move from Windows to Ubuntu, I lost a lot of my progress on my personal projects. I’ve also been very busy with work and spending as much time with my fiancee as I could.

But things are settling down and work is getting pretty interesting so I found out what I was allowed to talk about at work online and will hopefully be posting about that soon-ish (hope to get a real post out tonight).

My work keeps me primiarily in Flash/Flex and working closely with Electroserver so I will try to cover some of aspects of virtual world design and develop, multiplayer games and my new project, a Facebook game.

So check back later if any of that sounds interesting to ya and hopefully I’ll have a post or two!