[PLUGIN] TMX importer

Post your completed addons to share with the community

Post » Sat Mar 10, 2012 8:36 am

Here is the next version of tmx importer.








----

TMX importer
(Update:2013/07/06)

TMX (*.tmx) file is an output file of tile map editor. Plugin currently only supports two save modes.
- Base64 (uncompressed)
- CSV
Set save mode from menu bar "Edit" -> "Preferences"



Here is a sample capx.

The steps of using tmx importer for normal usage are:
1. load tmx string: "Action:Import tmx string". You can get tmx string from aJax.
- remember to replace " to ' if copy string into event sheet directly

2. create tile instances: "Action: Create tiles". This action will create instance, put instance into SOL, then trigger "Condition:On each tile cell" for each instance. You can do other customize.
- plugin will ignore tmx's invisible layer.
- plugin will create instance to THE SAME layer name. For example, layer name in tmx is "Ground", there should have "Ground" layer in capx.

- plugin will set the sprite frame to tile id. See the animation frame in sample capx file for more detail.


3. release memory: "Action:Release tmx object".


For advance user, step 2 can replace to "Action: Retrieve tile array". This action will not create any instance, it only trigger "Condition:On each tile cell" for each available cell. You can get properties stored in layer/tileset/tile to create instance manually.

See test_TMXImporter_adv.capx.

Execution flow

rexrainbow2013-07-22 07:20:17
Last edited by rexrainbow on Sat May 03, 2014 3:37 pm, edited 1 time in total.
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Sat Mar 10, 2012 9:07 am

How is the collision between player and the walls?delgado2012-03-10 09:08:52
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Sat Mar 10, 2012 9:12 am

@delgado

Collision polygon is defined in c2 (sprite editor), this plugin only
1. parsing tmx string
2. create instances to some position. (option)rexrainbow2012-03-10 09:24:39
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Sat Mar 10, 2012 5:34 pm

@rexrainbow
thank you
you deserve to go to heaven (at least C2-heaven)
not only for this plugin but for all the plugins you develop
B
28
S
3
G
1
Posts: 1
Reputation: 2,993

Post » Mon Mar 12, 2012 8:39 am

Wow, this is Awesome! Thank you! :)
B
27
S
3
G
6
Posts: 88
Reputation: 4,873

Post » Tue Mar 13, 2012 10:47 am

Update:

Add expression: total width, total height
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Thu Mar 15, 2012 9:40 pm

Hi,

I thank you for this lovely plugin. This is going to make me sound dumb but I'm having trouble understanding how this plugin works.

For now I will use your capx as a template to modify upon, but is it possible for you to show a more step-by-step tutorial?
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Fri Mar 16, 2012 12:37 am

Step0. edit tmx file by Tile map editor. Ensure the compression type to Base64 (uncompressed) or CSV


Step1. add "Action:Import tmx string",user can put string from tmx file or AJAX

Step2. add "Action:Set instance position of (0,0)". This action is used to tell plugin the real position of logically (0,0). (It's an offset of whole tiles)

Step3. add "Action: Create tiles". This action will
- a. create instances from tmx string
: layer name will be the same as in tmx

: x, y position will be calculated by logically index add offset (set in step2)
: set frame index by tmx tile id

- b. for each instance, put this instance into SOL
- c. (for each instance) then trigger "Condition:On each tile cell". User can get other data from "expression:LayerProp, TilesetProp, or TileProp". (User can edit these properties in tile map editor.)
Or use array object to store the "logic position to uid mapping". this array object is using to maintain the "logic world".

Step4. add "Action:Release tmx object" to release all data. After this action, "Action: Create tiles" will no longer to create instances.rexrainbow2012-03-16 00:41:13
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Tue Mar 20, 2012 3:34 pm

Update:

Add version to 0.1
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Sat Mar 24, 2012 3:34 pm

Update:

Fix bug at "expression:IsIsometric".


Here is a demo of using tmx importer and other (unreleased) plugins to create a board world.rexrainbow2012-03-24 15:38:04
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Next

Return to Completed Addons

Who is online

Users browsing this forum: andreyin, fernandochadu and 2 guests