I've started work on game 2 for game'88, and it's going to be a tile based scroller. Unbelievably after doing literally dozens of tile based games in as2, I've still not done one in as3.
First up I fired up Mappy, did some an ultra simple test map and then exported it using the lua based exporter I wrote way back. It's a nice simple format, eg
smf!|10|200|0,0|0,0|0,0|0,0|
We've got a bit of a header there, "Stimunation Map Format", now that's going back some years, the width and height of the map ( 10 tiles wide, 200 high ), and then a combination of the tile image|tile attribute.
In the good old days we'd just #include that and hit it up that way, but as3 doesn't give us include, so it's a swanky new byteArray approach for us.
As always reading code on a blog is just boring, so open up another tab and get some filth in there to flick over to when your eyes start to glaze, or maybe a youTube video of a cute cat.
package Classes.Game2.Scroller {
import flash.utils.ByteArray;
public class G2_LevelData {
//---------------------------------------------------------------------------------------
// Assets
//---------------------------------------------------------------------------------------
[Embed("/_assets/G2_level1.txt",mimeType="application/octet-stream")]
private var level1Data:Class;
//---------------------------------------------------------------------------------------
// Properties
//---------------------------------------------------------------------------------------
public var map1:Array;
private var mapData:ByteArray;
//---------------------------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------------------------
public function G2_LevelData() {
mapData=new level1Data();
var mapDataArray:Array=convertToArray(mapData);
}
//---------------------------------------------------------------------------------------
// Private
//---------------------------------------------------------------------------------------
private function convertToArray(source:ByteArray):Array{
var tempString:String=source.toString();
var tempArray:Array=tempString.split("|");
return tempArray;
}
//---------------------------------------------------------------------------------------
}
}
And that's it, almost too simple to share, but if it saves you a bit of hunting further down the line then it's not a bad thing.
Squize.