2D Toolkit Forum

2D Toolkit => Support => Topic started by: werzar on March 17, 2013, 01:02:29 am

Title: How to import a .tmx file??
Post by: werzar on March 17, 2013, 01:02:29 am
Hi all,

When I import a file. Tmx obviously need to load the sprite collection (data) but I dont know if I have to do this before importing or after, in any case I've tried both ways and is seriously wrong.

I tried an example of tiled program, the file name is desert.tmx case anyone tried it already or know how.

Any solutions??

Thx.
Title: Re: How to import a .tmx file??
Post by: evs on March 17, 2013, 04:24:05 am
Hello,

Just getting to grips with this myself

So here's my little TMX guide using desert.tmx and tmw_desert_spacing.png from the Tiled download as an example?

1. Menu -> Assets -> Import New Asset? -> tmw_desert_spacing.png   

   (Or drag it to the Project tab)

2. Menu -> Assets  -> Create  -> tk2d  -> Sprite Collection   

   (I name it here before saving)

3. In the Inspector -> Open Editor?   

   (This opens the SpriteCollection Editor, which I dock to stop it disappearing)

   Note: If you want to use a tk2dCamera in your Project, you can select it here

   (Amongst other things)

4. In the SpriteCollection Editor -> Create -> Sprite Sheet

5. Drag the tmw_desert_spacing.png from the Project to the Sprite Sheet Texture box

   (Or use the select button to open the asset window instead)

6. Click Set up at the prompt to go to Edit/Config and set the properties?

   Tile Width 32

   Tile Height 32

   Tile Margin X 1

   Tile Margin Y 1

   Tile Spacing X 1

   Tile Spacing Y 1

   Pad Extend

   Click Apply AND Commit

7. Menu -> GameObject -> Create Other -> tk2d -> TileMap (Beta)

8. In the Inspector -> Edit

9. Drag the Desert Sprite Collection Object from the Project into the Inspector's Sprite Collection data box

10. Inspector -> Tile Map Data -> Create

   (Save it - rename it if you like)

11. Inspector -> Editor Data -> Create

   (Save it - rename it if you like)

12.Inspector -> Import -> Import TMX -> desert.tmx

   (Commit - although the map will already show, better safe than sorry - may want to adjust the camera)

   
TA DA DONE!!!



cheers

evs


Title: Re: How to import a .tmx file??
Post by: werzar on March 18, 2013, 11:13:57 am
Yeah man!!! this is awesome!!! very thx for that...

I have a new question:

There is a good way to make collisions in Tiled and import in unity?

The only way to make that for me is:

- Load a .tmx file.(Used for background)
- Then add new sprites in front of .tmx to make sprites with collider to my plattformer game.

thx.

Title: Re: How to import a .tmx file??
Post by: unikronsoftware on March 18, 2013, 02:23:14 pm
If you set up the sprites in the collection with colliders, they will automatically work. i.e. if you set up your wall sprites with colliders.

You can't get the collision layer to import directly at the moment, but the method above is pretty robust - you can set up very complex collider shapes and have everything else just work after that.
Title: Re: How to import a .tmx file??
Post by: werzar on July 13, 2013, 09:50:30 pm
ey!!!!

With this update doesnt work this method to import a .tmx file into unity with 2d toolkit...

I have followed all the steps but the imported map is never the right.

Solutions?? Thx.
Title: Re: How to import a .tmx file??
Post by: unikronsoftware on July 13, 2013, 10:03:14 pm
1. What update?

2. Whats "not right"? Could you be a bit more specific?
Title: Re: How to import a .tmx file??
Post by: werzar on July 14, 2013, 10:04:01 am
1. Last version.
2. I follow all the steps and when I import tmx file, map is not equal to the map create in tiled, in this case example of desert...
Title: Re: How to import a .tmx file??
Post by: werzar on July 14, 2013, 12:01:29 pm
ok!!!! it works!!! thx!!!
Title: Re: How to import a .tmx file??
Post by: unikronsoftware on July 14, 2013, 12:15:18 pm
This has gotta be one of the most confusing threads I've followed :)
If you don't mind - what was wrong initially, and how did it suddenly start working?
Title: Re: How to import a .tmx file??
Post by: AbsurdInteractive on August 27, 2013, 10:24:44 pm
I was using the latest 2.1 2D Toolkit and followed the TileMap tutorial on the website. I created the TileMapTutorial Spritesheet. Next, I used the Tiled app to design my level in 2D and export the level in .tmx format. When I now click on Import TMX, the tile id's seem to be incorrect, even though I used the same original spritesheet for both. I was wondering if you had any suggestions on how to get this to work, or how to change tile id numbers?
Title: Re: How to import a .tmx file??
Post by: unikronsoftware on August 28, 2013, 10:58:44 am
This sounds like it could be a fairly new issue. Could you please email a repro case to support at unikronsoftware.com including the tmx?