Tiled Map Engine

Ok, let’s see.

  1. Yep - the CoronaTiled name is because the repo was saved as CoronaTiled (that was the original name) and you can’t change the name after it’s been created.

  2. Yep

  3. Yep

  4. Unfortunately, forked repos don’t allow issues, for some reason, so the issue tracker’ll be on the original page: https://github.com/superqix/CoronaTiled/issues

  5. Hm… It’s working for me. Any more information?

  6. Apologies, I changed the name from 8-bit.png to 8-bit_mario.png. If you download the newer commit, that problem should be fixed.

  7. That can generally be handled by setting the min- and magTextureFilter to “nearest”. I’ll have to see if Ceramic automatically scales tiles or not, also.

  • Caleb

re 6 - I can open it now thanks

re 5 - in the console I just see this (and separately there is the Mac report dialog that comes up).  I’m on simulator build: Version 2013.1161 (2013.7.12).   Did export the platformer level just to see if this fixed things but it didn’t…
 

2013-07-18 20:54:17.033 Corona Simulator[19168:707] The file sandbox for this project is located at the following folder:

    (/Users/Greg/Library/Application Support/Corona Simulator/CoronaTiled-master-849B7505F1423B47A5277C793373E1D9)

/Applications/CoronaSDK/Corona Terminal: line 9: 19168 Segmentation fault: 11  “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*

Gregs-MacBook-Pro:~ Greg$ 

(PS - wonder if it’s related to this somehow - was this understood/fixed? http://forums.coronalabs.com/topic/29681-tiled-map-engine/?p=191863  )

I’m not a very hard-core computer tech or anything, but I think a segmentation fault occurs when an address that doesn’t exist is attempted to be accessed. It’s not occurring for me, though, which is the odd thing. I’m on build 2013.1137, so I’m a little older than you, but that shouldn’t do anything, or at least I don’t think it should.

I really have no earthly idea what could be happening. The only thing I can think of is, if you really want the bug fixed, to start debugging it yourself. It doesn’t crash for me, or I’d debug it - when I open it, it works perfectly.

As for the other error you mentioned in your PS, that was fixed.

  • C

just reverted back from build 2013.1161 to 2013.1137 and it works now…doh!   Wonder what CoronaLabs did in the later build…we could lodge the whole project in as a bug & say it crashed the simulator?

Branch is merged!!!

https://github.com/superqix/CoronaTiled

Congrats to Caleb on a great addition to the project!

Hi Jedi - how does this compare to what was at " https://github.com/GymbylCoding/CoronaTiled"?  If we were just on this branch does going to https://github.com/superqix/CoronaTiled give us some features or bug fixes?  Which one should we look to from here on in?

They are now the same project–of course they’ve always been the same project, I was just a little slow on the merge request :) 

This is the way github works, when you want to make a change you “fork” the project–which lets you break it and add stuff–and once you are done your “merge” it back in the main project.

Make sense?

ok - just wondered if you had improvement that may have been in your branch that I haven’t seen yet? i.e. just that you mentioned the word “merge”…  which one should we go to now as the main source?  (still haven’t got my head fully around the “git” concept - easier to understand the one central repository previous concepts :slight_smile:  )

hi,

are xParallax,yParallax layer properties working now?

I have created 2 layers on Tiled and change its parallax properties with different values but the whole map moves at the same speed

thanks

@txarly:

Yep, they work, but only if you’re using the built-in camera system.

@greg886:

You can kind of envision the GymbylCoding/CoronaTiled page as my “work desk” for it, and the superqix/CoronaTiled page as the main public version. So now you’ll want to go to the superqix page for everything :slight_smile:

  • C

@Caleb - ok thanks - I’ve marked one a “stable” and the other as “daily builds” in my bookmarks to remember  :)

Can I ask a couple of general tile questions I’ve been trying to come to grips with & your advice:

a) What do you think is the optimal tile size?

 

b) How to handle background?  I have a background other than just a color, but rather a pattern.  Easiest would be (and I’ll try it out with memory stat’s enabled) put this as a tile.  Is this going to be OK?  Or is there a better technique noting it would be possible to have much larger tile sizes here, to limit the amount of display objects?   It’s almost as if you would want another map for this with larger tile sizes, but then tie the two together in terms of camera/movement…perhaps this is possible?

In tiled:2 layers each one with property values

layer 1


xParallax = 0.3

yParallax = 0.2

layer 2


xParallax = 0.5

yParallax = 0.2

and, i have this code but parallax doesn´t work i am missing something sure, any idea?

[lua]


    – Main EnterFrame Listener

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

    local function onEnterFrame()

    

    if gameIsActive == true then

        setPlayerVelocityX()

        map.updateCamera()

    end    

    end

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

    – Add Listeners

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

    Runtime:addEventListener(“enterFrame”, onEnterFrame)

    DpadBack:addEventListener(“touch”, move)

    jumpBtn:addEventListener(“touch”, jump)

    map.setCameraFocus(player)

    map.setCameraBounds(

        display.contentCenterX, map(“mapWidth”)*map(“tileWidth”)-display.contentCenterX,

        display.contentCenterY, map(“mapHeight”)*map(“tileHeight”)-display.contentCenterY

    )

[/lua]

Physics Question - Is there a way to define a custom physics shape for a tile, that will come across to Corona?   

For example say you want “grass” sticking up 1/2 tile above the horizontal concrete, with the top 1/2 of the tile being transparent.  So you only want a player to “touch” the grass after they are 1/2 way coming down through that tile.   Options would be as follows I’m guessing, which one would be best:

Option 1 - Specify path in Tiler & this passes through an Ceramic handles this (not sure if this is what you do now - guessing nt)

Option 2 - If Ceramic is where you specify the physics path, then I guess extend Ceramic to the path you want.  You would have to extend it in a way that it doesn’t get overwritten or “break” future Ceramic releases.  

Option 3 - Upgrade Ceramic to have ability to take a custom path from Tiler (specified in a property) and use this.

Others?  Which one would you recommend?   I’ll need to do it somehow.  Could specify an object location with a file name and then in my code manually add in an image piece with a physics boundary, however it would seem it would be nicer if you could specify/handle it via the Tiler map…

Let me know if I should add it the issues register as a feature request…

PS. Discovered the json support.  Tried putting these two parameters on a specific Tile Property, however it did not reduce the physics area for the tile down any.  

Question:  What’s the correct usage of “physics:shape” and how it works?  (for a tile)

physics:enabled,  true

physics:shape,    “!json![-16,0,16,-16]”

I did note that if I set “physics:enabled” to false for the tile, then it did drop off physics against all those tiles in the map (cool)

Any properties prefixed by physics: are added to the physics table:

[lua]

physics.addBody(myObj, { })

                        |

                   Physics Table

[/lua]

So physics:shape is just the shape of the tile. JSON should be used to define it, just as you’re doing, but it would appear that you only have 2 points: -16,0 and 16,-16 which should make a ramp line shape. However, it should work with any amount of points* - including two. Is it simply not adding the body, or…?

Glad you like the per-tile abilities… They _are _pretty cool, if I do say so myself - and I do say so :smiley:

  • C

* Limited, of course by Corona’s 8-point max

ok I see, wasn’t really sure and just was guessing from the example it might have been a rectangle, but understand now - so the pixcel figures are relative to the center of the tile?

Also learned about using objects (like the platform example) to set a physics line, so this may be even better depending what you’re trying to do in the map…

Did you see my two question a few items up at: http://forums.coronalabs.com/topic/29681-tiled-map-engine/?p=193637  by the way?  Would be interested in your take…

Ok, time for an update on progress.

Note: These functions are all within the map object (created with .buildMap())

Culling is working just about perfectly (no bugs, no tile “leaks”) and is really amazing. Culling works faster the (a) larger tiles your map is made of (b) the less layers you have or © the less tiles you have (obviously). It’s pretty fast anyway, but it’s not such a good idea to use solid-colored-tile tiled backgrounds (repeating a solid colored tile to make a solid colored background), because it can slow down the culling engine part. Culling supports scaled maps - set your map xScale and yScale and then call resetVisible() and it’ll internally calculate the max visible tiles.

The camera system is working well, but it doesn’t support scaled maps. The map tracks an object specified with setCameraFocus(), sets bounds with setCameraBounds(), and moves+culls tiles with updateCamera().

You can lock tiles from being culled with setLock (iterates through chunk x1-x2, y1-y2). It takes five arguments. The first four are the dimensions of the chunk, and the last one is the lock state. A lock state of [lua]true[/lua] will lock tiles from being culled, and a lock state of [lua]false[/lua] will release any lock on the tiles. The lock state defaults to [lua]true[/lua].

You can manually draw tiles with draw(), manually erase tiles with erase(), and do auto-culling with render().

Alternatively, each layer (map.layer[index/key]) has their own versions of the drawing functions, so you can do them to a single layer with [lua]map.layer[“myLayer”].render()[/lua] or [lua]map.layer[1].render()[/lua].

Individual tile and object physics and properties are supported (edit tiles within a tileset or an object’s properties). Any property can be read as a table by starting the value out with [lua]!json![/lua] and then the value. So for a collision filter, you’d use this as your Tiled property:

[lua]

physics:filter     ::    !json!{“categoryBits”:2, “maskBits”:3}

[/lua]

(or something to that effect).

The type and name values for objects are stored in each object as “_type” and “_name”. If no name is found, it defaults to the shape + the object number; i.e. “rect5”.

Debug messages may be shown with [lua]ceramic.showPrints=true[/lua].

Single tiles are accessed with [lua]map.layer[“myLayer”].tile[x][y][/lua]. Single objects are accessed with [lua]map.layer[“myLayer”].object[“myObject”][/lua].

Each layer has two references; a numerical index and a string key equal to the layer’s name. Objects are done likewise; each object has an index reference and a key reference equal to their name.

That’s all the framework I can think of at the minute, but if I think of something else that’s really cool, I’ll comment again.

HI Caleb - fyi - just put in an issue here:  https://github.com/superqix/CoronaTiled/issues/8  “vertical column of tiles missing in iPad view of simulator”.

Sounds very cool. I like the !json! bit… Maybe there’s a way to do that by checking if the data has matching braces and assuming it’s JSON.

I think the plan should be to keep the current map rendering as a Ceramic:preRender(mapdata) for people who want to get a simple map (think puzzle games) up easily and make all this new stuff the default renderer.

Also posted your documentation on the GitHub wiki here…

https://github.com/superqix/CoronaTiled/wiki/Documentation