Posts Tagged ‘cross-platform development’

3 tips for working with haxelib

Wednesday, August 13th, 2014 by Phillip Napieralski

Tip 1 – Pointing haxelib library to git repository

Did you just fork flixel-addons to tweak an out-of-date control? I recently had to do this to add touch support to FlxButtonPlus – this is truly the power of open source!

Here’s what you can do:

haxelib git
> Library name : flixel-addons
> Git path : <paste git repository URL here>

Now, wait for the download to finish and confirm everything is working as expected by doing:

haxelib list 
> actuate: [1.7.5]
> firetongue: [1.0.0]
> flixel-addons: 1.1.0 git [dev:C:\HaxeToolkit\haxe\lib\flixel-addons/git]
> flixel-demos: [1.1.1]
> flixel-editors: git [dev:C:\HaxeToolkit\haxe\lib\flixel-editors/git]
...

In the output, you see that flixel-addons list two options, a stable version 1.1.0 and the actual git repository.

Tip 2 – switching between haxelib versions

Now that you have a stable 1.1.0 version and the git version, you will automatically be working using the latest and greatest in the git repository. But, what if you aren’t ready yet?

Here’s how to compile using flixel-addons version 1.1.0 – this works with all haxelibs and versions:

haxelib set flixel-addons 1.1.0

Likewise, if I wanted to downgrade/upgrade anyother library, I could via haxelib set

Tip 3 – keeping everything up-to-date

To keep everything up-to-date, there are two ways:

1. Upgrading an individual haxelib:

haxelib update <haxelib name, eg; flixel-addons>

If the library is pointing to a git repository, it will simply do a pull from the git repository (how cool is that?).

2. Upgrade all haxelibs at once

haxelib upgrade

Now wait… boom, done!

How to create a starfield in 5 lines of code (or less)

Wednesday, June 25th, 2014 by Phillip Napieralski

I recently ported my simple starfield demo over from actionscript/flixel to haxeflixel with create success and ease.

However, there’s an even easier way with the flixel addons!

Overview

Let’s see what the final result will be like – check it out:

Now that I have your attention, let’s take a quick walk through the steps to get this starfield running:

  • Install flixel addons
  • Add flixel addons to your project – one line of code
  • Add imports to your FlxState – one line of code
  • Create your starfield – 1-3 lines of code

Install flixel addons

Type this:

haxelib install flixel-addons

Afterwards, type

haxelib list

…to see what plugins you already have installed and ready for consumption.

Add flixel addson to your project

Add the following to your Project.xml file (which should be in the root directory of your project folder:

<haxelib name="flixel-addons" />

You’ll see this listed, but commented out by default, under the “libraries” section of your xml file.

Add imports

Add the following to the top of the file where your starfield will be created and used:

import flixel.addons.display.FlxStarField.FlxStarField2D;

Create the starfield!

Now that you’re all set-up, let’s create the starfield. Here’s some simple code to create the starfield and adjust it’s speed:

var starField:FlxStarField2D = new FlxStarField2D(0 /*X*/, 0 /*Y*/, FlxG.width, FlxG.height, 300);
starField.setStarSpeed(1, 80);
		
add(starField);

Put this code somewhere in your create method and feel free to modify the star speed anytime. There is also a similarly named FlxStarField3D.

Find it on github

I posted a super small sample that you can download and use with flixel addons version 1.1.0. Have fun!

Hope that helps!

How do I change the icon for my HaxeFlixel project?

Tuesday, June 24th, 2014 by Phillip Napieralski

Overview

It’s quite simple to swap out the icon for your haxeflixel project. Supposing you already have a project created, there are two main steps:
1. Create a new icon and export it as a SVG file.
2. Update your Project.xml file

Step One – Create a SVG file

An SVG file is used to save vector art – something that can, essentially, be scaled in any direction infinitely without losing it’s clarity. This is especially important for icons, that may needed in various sizes, especially on Android.

Because I love open-source technology, I chose to create my dinky Face Defender game logo using InkScape. Load it up and make your logo!

Once you’re done, save it as icon.svg and put it in your projects assets/images folder.

Step Two – Update your project.xml file

This part’s easy. Add the following to your project.xml file:

<icon path="assets/icon.svg"/>

That’s it! Build and test with “lime test Android” and see the icon difference. Haxe uses built in tools to scale the svg file appropriately and encode as a png file.

Face defender is now on Google Play

Friday, June 20th, 2014 by Phillip Napieralski

What do you do when you want to learn a new cross-platform language like Haxe? Port one of your ancient/dinky flash games to it!

On Google Play / flash version

While I have the app working on Google Play now (so you can try it on your android devices) – the real power behind haxe is the ability to be completely cross platform. So, here’s the flash version, have fun!

Porting experience

I started looking into Haxe, specifically HaxeFlixel, about two weeks ago while searching for an awesome cross-platform API. While HaxeFlixel still doesn’t support Windows 8/WP8, I’m confident someone out there is working on it.

Regardless, the experience going from Flixel in actionscript to HaxeFlixel has been great so far. Everything with HaxeFlixel seems very familiar to what I’m used.

Time spent / conclusion

I spent a weekend on porting this game. And, while there are a couple quarks and differences from the original flixel version, it’s more or less the same experience (aside from the sound effects and music, which I lost somewhere!).

So, whether it be haxeflixel or some other cross-platform toolkit, I’m sold on the idea of using cross platform tools. It’s especially nice being able to post my games on my wordpress blog as flash and also on the android marketplace with minimal overhead.