Flixel Forums

development => help => Topic started by: Titch on Mon, Jul 27, 2009

Title: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Mon, Jul 27, 2009
Writing a level editor is a pain. Why do that when you could just use a tileset editor like Tilestudio or Mappy to lay out the level. Since Flixel uses a really standard text array input for tilesets, it's absolutely ideal for using a tile based mapping program to edit with. This is the meathod I've been using to work on my Flixel based game  Level Up (http://www.niftyhat.com/level_up/)

To lay it out, this method uses FlxTilemap and you need to download a copy of Mappy (http://www.tilemap.co.uk/mappy.php) and this  script file + examples (http://www.niftyhat.com/posted_stuff/mappy_tut01.zip) that plugs in to Mappy to output the map in a format that Flixel can understand.

First you need to prepare you tileset, if you haven't already. As far as I know all tiles in Flixel have to be square and laid out in strips. It's important to note that non-colliding tiles go at the START of a tilestrip. If you have to change the arrangement of tiles in the strip at a later point it will play absolute HAVOC with your map. Unless you are 100% CERTAIN, leave some space for later.

(http://www.niftyhat.com/posted_stuff/example_chip.png)
Here is an example set if you don't want to make your own just to try this out. Based on my previous advice this is crappy layout for the tiles, but I was trying to minimize the size of the file.

So the first job is to set up the script for use in Mappy. Once you've downloaded Mappy itself you need to extract the script file to the /luascr/ folder inside the directory with the mapwin.exe. You also need to edit MapWin.ini and add the extra script into the custom script menu, by scrolling down to where it says:
Code: [Select]
;
;    lua scripts
;    these are files in the luascr folder, they are textfiles that allow
;    custom functions to be written (see www.lua.org for language details)
;    to add them list them here preceded by lua01 to lua16, they appear
;    in the Custom menu. You can also drag and drop .lua scripts onto the editor
;
And add this at the bottom of the list
Code: [Select]
lua16=Export Flixel Tilemap.lua(In my setup, I replaced the flash script with the Flixel one to put it at the top of the menu)

Now open up Mappy. Open the File menu, select that you want to make a New map. You have to input the dimensions of the tiles and the number of tiles in the map. If you are just testing the functionality you will probably want to downsize the map from 100x100 to something smaller. If you are using the example chipset, set your tile size to 16x16. Then hit File and then Import. Select the file you want to import and they should pop up in the right hand column.

Now draw your Map. Mappy has a ton of different functions that I don't really want to go into right now. This method doesn't support animated tiles. If you want to do layers they have to be exported seperately and then arranged to be added in order in the code. In the future I'm going to update the export script to better handle multiple layers (or someone else can to).

Once you map is drawn out. Go to the Custom menu and select Export Flixel Tilemap. It will ask you to provide a filename and set an amount to shift the tiles by (It's best to leave this at -1 unless you know what you are doing). You should then get a big long comma delimited textfile full of numbers that you can import using FlxTilemap.

Setting up the map in game is a simple as  

Quote
[Embed(source = "data/example_map.txt", mimeType = "application/octet-stream")] public static var data_map:Class;
[Embed(source = "data/example_chip.png", mimeType = "application/octet-stream")] public static var data_tiles:Class;

var myMap:FlxTilemap;
myMap= new FlxTilemap(new data_map, new data_tiles, 3, 1);
add(myMap);

Obviously you substitute example_map.txt for your own generated txt file from Mappy and example_chip.png for your own chipset when working on your own map. It's worth note that you can import multiple maps this way and layer them infront/behind the character. The main collision map is a good place to put other deco objects that appear in front of the player. I usually set up another map that is added before the player sprite as a background area.

OTHER NOTES AND STUFF:

I will update the Mappy export script to handle better layers nicely.
I will add some kind of compilable flash code to demonstrate this.
There are still some bugs with tiles not appearing correctly in Flixel. I will also adress these in the near future.
For some reason I still can't get Mappy to see transparncy on my tilesets. If anyone else has any luck with this please let me know.

Oh, and I'm sorry for being needlessly verbose >_>. This turned out to be really handy for me, so I hope it can help others.
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Adam Atomic on Mon, Jul 27, 2009
F*cking radical my friend :D  Added to the general help thread
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: ahref on Tue, Jul 28, 2009
Thank you seems miles simpler than the other methods i have read. Which is good for me as a beginner.

I would love a compileable example though.

Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: allenp on Tue, Jul 28, 2009
Perfect - thank you. This makes it sound so easy!
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Wed, Jul 29, 2009
I'll get some more complete/compileable examples up in the next few days. I wrote this method as part of the project I'm busy working on, so when time permits I'll take a break from it and work on tutorializing this stuff better.

Since I posted this I wrote another version of the same script that compiles the entire tilemap to XML and can handle an entity list so you can populate your map with enemies/pickups whatever else. So I want to write an alternative version of the tutorial for that to...
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Mr Dumle on Sat, Aug 1, 2009
Please do!  :D
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Sat, Aug 1, 2009
Script is written. Tutorial is...not. I'm working on making a complilable example that is both elegent and readable. I'm hitting a ton of roadblocks to do with the fact mappy can't associate information with LAYERS it can only associate info with blocks. This makes it a pain to work out how to assign parallax/collision when importing into flash.

ZEE SCRIPT + SAMPLE XML OUTPUT (http://www.niftyhat.com/posted_stuff/export_script_xml.zip)

Basically you end up with an XML file with two lots of nodes. Layers and Objects. Once you've got the xml into flash you can simply write something along the lines of

Code: [Select]
for each (var layer:XML in xml_map_data)
{
add FlxTilemap(layer,tileset);
}

Simple. Only it isn't. Because you need a few bits of data when you bring the map in, like which layer is the collision layer or layers if you want to waste a bunch of processing power on arrays. Since you can't write this information in Mappy, the only other options are.
a) Add it into the XML manually. This will play hell with the fast pipeline this system was supposed to set up because re-export the map murders the custom tags
b) Hardcode it into the game. I did this in Level Up. So my layers are done like this
Code: [Select]
m_main_map = new FlxTilemap (map_data.layer[2],main_chipset,63,1);
m_parallax_map = new FlxTilemap (map_data.layer[0]);
I consider this solution LESS than awesome for a tutorial simply because it's so inflexible. Although it does make for nice and readable code.
c) Write some external text/xml file that Mappy can read and get parameters from. So when you make your map you also create a MapInfo.txt that you select when you run the script and it autogenerates the XML based off the parameters in the file. I am slightly dubious as to how achiveable this is, my experiance with Lua isn't amazing.

XML DOES have the nifty feature of an object list. Basically you place down a marker tile in Mappy. Set the tiles user value to X. The output will then add that tiles location to objects as:
<OBJX x="" y="">
Again you can easily read this off and use it to instantiate enemies/pick-ups or anything else that isn't a tilemap. In the near future I would like to add support to be able to associate object values with names. So instead of getting OBJX you would get "COIN" or whatever you write in for the tile string. I would also like to add support for more custom value. Since mappy tiles can carry up to 7 id's you could have 6 other unique bits of data like health, value, speed, whatever else.

Anyway, I've rambled on enough for 2am. Good luck and I'll be back in a few days with a real tutorial with code, pictures and lord knows what else.
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Trufforce on Fri, Sep 11, 2009
Do you think it would be possible to have a layer to position the sprites, maybe using an array of FlxSprites?
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Fri, Sep 11, 2009
I used marker tiles to position my sprites, because a whole layer of data is a bit excessive to record a handful of sprite positions. Plus I it allows me to record more information on the marker tiles to be included in the XML, like speed, health, value or whatever else.

So you double click on a tile to open it's block properties set it's user value 2 to the reference you want for that sprite in game and then place it on a separate layer that you aren't using (which is in essence your sprites layer, it's just you are going to junk the acctuall layer data in the XML cos you don't need it).

(http://i80.photobucket.com/albums/j197/Titch007uk/mappy_tut1.png?t=1252692555)
Like so.

Then to translate that into an array you just need a little snippet of code this this:
Code: [Select]
var list :XML = Library.level_data.objects[0];
var item:*
var o:XML
for each (o in list.OBJ6)
{
m_enemies.push(new LevSpiker (o.@x, o.@y));
}
for each (item in m_enemies)
{
m_layer_game.add(item);
}

Each .@x parameter specifies a bit of data in the xml entry for that object, so you could potential encode extra data on the marker tile and mod the script so that you could so something like

Code: [Select]
m_enemies.push(new LevCustomEnemy (o.@x, o.@y, o.@strength, o.@money))

Or whatever.

The two big caveats to this is one that the objects list is an unreadable mess. Which is a limitation of mappy, I can't work out how  easily associate strings with tiles. The other is that the XML will contain a layer of junk data or your sprites layer. Which needs to be deleted pre-release (theres no point in deleting it during development because the mappy XML output will just generate another one) which is also because there is no function in Mappy for checking the name of the layer. Although I am considering just having it omit the highest layer.

Given that Flan is out now, I think the whole Mappy solution is a little bit hacky and you might be better of directing your intrest at that.
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Trufforce on Sat, Sep 12, 2009
ah ha, thanks  ;D
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: knugen on Thu, Sep 17, 2009
This is an awesome method for level creating, thanks for sharing :D

I was playing around with my own camera movement on maps created with this, and while doing so I used the height and width properties of the FlxTilemap to determine the "camera bounds". Turned out though that height was exactly one tile bigger than it should be, and this was due to an extra, empty, line in the map text file.

It could of course be removed easily, but it would be a tedious thing to do each time you export a map so I took a look at the Lua script file (for the exporting): It adds a seemingly unnecessary new line just before finishing up, so I prevented that by commenting it out (the affected line is #50).

Code: [Select]
...
y = y + 1
end
-- outas:write ("\n") -- Unnecessary (?), so "removed"
outas:close ()
...

Of course it would be best if FlxTilemap removed empty lines before doing anything else, it's quite easy to do so I definitely think it should be in the next release. I could make a mod on my own, but for now I'm satisfied with just removing that line ;D
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Fri, Sep 18, 2009
Well I am going to do one more release of this before I port over to Flan for my mapping purposes, so kudos for spotting that and I'll make sure to adjust the script accordingly. The trailing /n is probably a remnant of when I was trying to make sure the XML formatted correctly (FlashDevelop doesn't nicely auto format XML and I don't like trying to read a mess  ;) ).
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Rybar on Wed, Oct 14, 2009
Mappy crashes on me when importing any PNG tile strip, even with the extra DLL's mentioned on the Mappy webpage.  If I re-save the images as bmps, it works. but I would like PNGs to work, for transparency.  Anyone else having this problem?
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Thu, Oct 15, 2009
I had this problem initially, I think on my Vista computer.

I can't remember exactly how I solved it, I think I got the DLL from another source or had to move the file to a new location. Sorry I can't remember more specifically, it was a while ago when I set it up.
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: jordan_magnuson on Wed, Oct 21, 2009
Quote
Mappy crashes on me when importing any PNG tile strip, even with the extra DLL's mentioned on the Mappy webpage.  If I re-save the images as bmps, it works. but I would like PNGs to work, for transparency.  Anyone else having this problem?

Just in case anyone's still having this problem: I had to put the dll files from here (http://www.tilemap.co.uk/pngfiles.html) in my windows/system32 directory to get png's to work on Windows XP.
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Polaris666 on Sun, Nov 22, 2009
I'm testing this to see how it goes, and it's pretty cool, I ran into a problem though.

I made a .png of 32x16 with a couple of 16x16 tiles. I then did a map on Mappy,  exported it with the script and when I load it onto Flixel... I found that the very first tile type wasn't showing up.

So I go an check the .txt file and to my surprise the numbers that were supposed to be the first tile had only 0's on them, just like the black tile that Mappy adds by default to any tile strip imported. After seeing that I figured that the -1 was to compensate for that black tile.

What is the best way to handle this? Do I make my tile strip so that it includes a transparent tile at the beggining, and use that instead of the default used by Mappy? Or there is a better way, I sure hope so.

-------------------------------------------------------------------------------------------------

Update: My bad I just read again the Basic Tutorial and that last thing I wrote is pretty much the way to do it... Yeah I feel real dumb right now :P
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Sun, Nov 22, 2009
I later discovered there is a way to stop Mappy stripping that tile out in the mappy settings. If you put
Code: [Select]
importskip=2
In MAPWIN.INI it stops stripping early tiles out. You might want to edit the defualt for the script to point at 0 if this works so you don't have to keep changing it.

I really should update this tutorial, but it's kind of split into two scripts now when I had to do a re-write so I'm not sure if I should keep the two versions running together or cut one out. The newest version I have only takes objects from the top layer so it can automatically strip the tile data out of the XML file and save a bit of space.

I've also been thinking about adding an alternate tile loading script so that you can easily 'refresh' a strip you already loaded rather than having to re-import it.
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Scrufalicious on Tue, Nov 24, 2009
Okay, so I'm VERY new at programming/making games, so it's quite possible this answer is fairly obvious and I'm just a buffoon, but using Mappy, can you make the non-tile portion of the map = 100% alpha (See through) so that you can put a LARGE image in the background opposed to just meticulously adding it AROUND platforms that are in the background image. Because the issue I have is this:
(http://i303.photobucket.com/albums/nn148/Scrufalicious/Mockup.png)
The top picture shows me putting the image in FRONT of the map.txt layer, which covers up all platforms, and the bottom picture shows me putting the image behind it, which is COMPLETELY covered up by the black background that exported with Mappy.

I'm not necessarily trying to 100% make a game yet, I'm just trying to see what I can/cannot do with Flixel and have been stuck on this issue all day...  :-[ Any help would be MUCH appreciated!
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Tue, Nov 24, 2009
Try setting drawIndex on Tilemap to 1 so it skips drawing all 0 tiles so they don't block visibility. So when you add the tilemap to your stage just set the fourth parameter on new FlxTilemap to something greater than 0, and then make sure all your non-collision transparent tiles are lower than that.

function FlxTilemap (MapData : String, TileGraphic : Class, CollisionIndex : uint, DrawIndex : uint)

I'm pretty sure I've never had this problem before though. Would you mind posting your map.xml for me to have a look at?
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Scrufalicious on Tue, Nov 24, 2009
Dang! I was hoping that was going to fix it because it totally makes sense, but then I looked at my FlxTileMap.as and my DrawIndex uint is already = 1:

(http://i303.photobucket.com/albums/nn148/Scrufalicious/FlxTileMap.png)

This is the map.txt file, is that what you mean for the .xml file? Because I feel like this is the only file related to it I have, if I'm supposed to have more, perhaps that's the problem?  :-\

(http://i303.photobucket.com/albums/nn148/Scrufalicious/xml.png)
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Scrufalicious on Wed, Dec 2, 2009
Still curious if anyone knows how to fix this. Haven't heard any responses and I'm stumped...  :-\
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: shortstalker on Sun, Dec 13, 2009
I've rewritten the LUA code attached above to export multiple layers.

When you give your map a name, say text.txt it exports the layers as:

text_L0.txt
text_L1.txt
text_L2.txt
etc...


I can't seem to get it to upload, so here it is in code form.

Enjoy!

code:
Quote
-- Export Flash actionscript
-- Thanks to Andre Michelle for the idea
-- multiple layer mod. by Mike


function main ()
 if mappy.msgBox ("Export Flixel Tilemap", "This will export the current layer as a Flixel Tilemap (anims are replaced with block 0)\n\nRun the script (you will be prompted for a filename to save as)?", mappy.MMB_OKCANCEL, mappy.MMB_ICONQUESTION) == mappy.MMB_OK then

  local w = mappy.getValue(mappy.MAPWIDTH)
  local h = mappy.getValue(mappy.MAPHEIGHT)
  local layers = mappy.getValue(mappy.NUMLAYERS)

  if (w == 0) then
   mappy.msgBox ("Export Flash actionscript", "You need to load or create a map first", mappy.MMB_OK, mappy.MMB_ICONINFO)
  else

   local isok,asname = mappy.fileRequester (".", "Flixel Tilemap (*.txt)", "*.txt", mappy.MMB_SAVE)
   if isok == mappy.MMB_OK then

    if ((string.sub (string.lower (asname), -4) == ".txt")) then
     asname = string.sub (string.lower (asname), 1, string.len(asname)-4)
    end

    local isok,adjust = mappy.doDialogue ("Export Flixel Tilemap", "Adjust exported values by:", "-1", mappy.MMB_DIALOGUE1)
    if isok == mappy.MMB_OK then
   
     adjust = tonumber (adjust)
     local l = 0
     while l < layers do
       outas = io.open (asname .. "_L" .. tostring(l) .. ".txt", "w")
       local y = 0
       while y < h do
        local x = 0
        while x < w do
         local mapval = mappy.getBlockValue (mappy.getBlock (x, y, l), mappy.BLKBG)
         mapval = mapval + adjust
         if mapval < 0 then
          mapval = 0
         end
         outas:write (tostring(mapval))
         if x < (w-1) then
          outas:write (",")
         else
          if y < (h-1) then
      outas:write ("\n")
     else
      outas:write ("\n")
      end
         end
        x = x + 1
        end
        y = y + 1
       end
        outas:write ("\n")
   outas:close()
       l = l + 1
      end

    end
   end
  end
 end
end

test, errormsg = pcall( main )
if not test then
    mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
end

Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Sun, Dec 13, 2009
Ummm, the code already exports multiple layers. The whole point was the create a system where a bunch of layers are all embedded into one XML.

Not that having a pure text export is a bad things :P
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: shortstalker on Sun, Dec 13, 2009
My bad, the lua that I got was from the starter tutorial that makes the Ninja game. I didn't bother looking at the LUA you had created because I thought they were the same.

cheers!
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: murkinesis on Thu, Dec 17, 2009
Titch,
do I understand that your new script can export multiple layers in one map? If so, how do I import an XML map rather than a TXT one?
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: PlayOrDie on Sat, Dec 19, 2009
Not that having a pure text export is a bad things :P

@Titch

Your solution using marker tiles (by editing mappy's block properties) for Flixel sprites seems clean enough, I am going to try it out your example code and script tonight.

@shortstalker

Having the layers as separate text files seem reasonable enough - if slightly less efficient than a single XML (I know you didn't notice that), but my main concern with your method of multiple txt files is how to parse the sprite layers csv (txt file) into an array of integers for sprite placement.

[EDIT]

Titch,
do I understand that your new script can export multiple layers in one map? If so, how do I import an XML map rather than a TXT one?

I tried this out tonight and also had problems embedding and parsing the xml file that is exported from Mappy.  All 3 layers in the supplied example seem to export correctly when I looked at the resulting xml file in notepad, however I am also not sure how to deal with this in Flixel, despite Titch's guidelines earlier in this thread.

@ Titch: forgive my directness, but would you mind helping us poor xml noobs a bit more with importing into flixel and setting up the layers? :)  Even the xml embedding tutorials I found on the www didn't seem to make it work for me after trying for an hour or two.  Also, thanks for the great help so far with mappy.
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Titch on Sun, Dec 20, 2009
I'll see what I can do. I mentioned somewhere a while back that the script now has two 'branches'. A generic version and a *Up development version. I probably won't have time to write anything up untill after christmas now. :|
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: jeanpier on Mon, Dec 21, 2009
I have been playing with mappy and lua today. And I modified the script a little to:
Layer0-> Export tiles (level_tiles.txt)
Layer1-> Export sprites (level_sprites.txt)

The sprites are adjusted to -91, so I have a lot of space for my tiles if I need a couple more. This way I can work with a single bitmap.

Notes: My tilemap has the first tile black (no need to adjust -1, removed). Sprites are 40x40. Sprites are positioned starting 90 tiles below (adjust -90), so my sprites array start at 01 in my level_sprites.txt.
The combined tiles/sprites bitmap is only used in Mappy just for reference.

Just look the script and adjust the second layer to your needs (adjust = startSprites - 1).

Something simple and very not optimized but works for my maps so far.

Code: [Select]
-- Export Flash actionscript
-- Thanks to Andre Michelle for the idea
-- multiple layer mod. by Mike


function main ()
 if mappy.msgBox ("Exportar Flixel Map", "Esto exportara dos Layers. El primero con los Tiles y el segundo con los

Sprites.(Deberás proporcionar un nombre para guardar el mapa)", mappy.MMB_OKCANCEL, mappy.MMB_ICONQUESTION) == mappy.MMB_OK

then

  local w = mappy.getValue(mappy.MAPWIDTH)
  local h = mappy.getValue(mappy.MAPHEIGHT)
  local layers = mappy.getValue(mappy.NUMLAYERS)

  if (w == 0) then
   mappy.msgBox ("Exportar Fixel Map", "Necesitas cargar o crear un mapa primero", mappy.MMB_OK, mappy.MMB_ICONINFO)
  else

   local isok,asname = mappy.fileRequester (".", "Flixel Tilemap (*.txt)", "*.txt", mappy.MMB_SAVE)
   if isok == mappy.MMB_OK then

    if ((string.sub (string.lower (asname), -4) == ".txt")) then
     asname = string.sub (string.lower (asname), 1, string.len(asname)-4)
    end
      -- Layer 0 TILES

  adjust = tonumber (0)

     local l = 0
       outas = io.open (asname .. "_tiles" .. ".txt", "w")
       local y = 0
       while y < h do
        local x = 0
        while x < w do
         local mapval = mappy.getBlockValue (mappy.getBlock (x, y, l), mappy.BLKBG)
         mapval = mapval + adjust
         if mapval < 0 then
          mapval = 0
         end
         outas:write (tostring(mapval))
         if x < (w-1) then
          outas:write (",")
         else
          if y < (h-1) then
      outas:write ("\n")
     else
      outas:write ("\n")
      end
         end
        x = x + 1
        end
        y = y + 1
       end
        outas:write ("\n")
   outas:close()
       l = l + 1

-- Layer 1 SPRITES

   adjust = tonumber (-90)
   outas = io.open (asname .. "_sprites" .. ".txt", "w")
       local y = 0
       while y < h do
        local x = 0
        while x < w do
         local mapval = mappy.getBlockValue (mappy.getBlock (x, y, l), mappy.BLKBG)
         mapval = mapval + adjust
         if mapval < 0 then
          mapval = 0
         end
         outas:write (tostring(mapval))
         if x < (w-1) then
          outas:write (",")
         else
          if y < (h-1) then
      outas:write ("\n")
     else
      outas:write ("\n")
      end
         end
        x = x + 1
        end
        y = y + 1
       end
        outas:write ("\n")
   outas:close()
   end
  end
 end
end

test, errormsg = pcall( main )
if not test then
    mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
end
 
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: Barts on Sun, Feb 21, 2010
I just wanted to express my thanks to Titch and Shortstalker.

I have tried meddling with Flan and WasabiM and neither really pleased me, both crashed and I had problems integrating output with my file. Maybe I am just dumb. Still, I considered writing a C++ program to convert XML output of TileEd to something Flixel-readable, but then gave Mappy plus scripts a chance - and it turned out to be reasonably comfortable and rather easy to use.

Thanks a bunch, guys!
Title: Re: Drawing Tilemaps for Flixel using Mappy.
Post by: jonathanbruder on Sat, Apr 3, 2010
First of all, thanks much for posting this.

I'm working through part two of Seifer Tim's tutorial, and have used the method here to create my map with mappy.
Code: [Select]
 package com.Tutorial
{
    import org.flixel.*;

    public class PlayState extends FlxState
    {
[Embed(source = '../../org/flixel/data/tutorial-tiles.png')] private var ImgTiles:Class;
         [Embed(source = '../../org/flixel/data/map.txt', mimeType = "application/octet-stream")] private var GameMap:Class;
        
...

When I try to publish, I get the following error, followed by a repeated error that seems to be happening on update:

Quote
[Fault] exception, information=VerifyError: Error #1014: Class mx.core::ByteArrayAsset could not be found.
[Fault] exception, information=ReferenceError: Error #1065: Variable PlayState_GameMap is not defined.
flixel v2.32 [debug]
----------------------------------------------------
[Fault] exception, information=ReferenceError: Error #1065: Variable com.Tutorial::PlayState_GameMap is not defined.
Fault, PlayState() at PlayState.as:7
[Fault] exception, information=ReferenceError: Error #1065: Variable com.Tutorial::PlayState_GameMap is not defined.
Fault, PlayState() at PlayState.as:7

I'm (fairly) certain that flex.swc is in the correct place and that my AS3 context is correct. The reason I'm posting this in this thread is that the error disapparates when I comment out the map code. As expected, my player appears on screen and falls to his doom; no error.

I understand that ByteArrayAsset is automatically extended when you embed an octet-stream file. I just don't get why it seems to be glitching.

My map file contains the expected array of tile numbers and nothing else.

Thanks in advance for any help.

--Jonathan Bruder