Page 7 of 92

Re: Simple Tiled Implementation - STI v0.6.12

Posted: Fri Jan 31, 2014 9:24 am
by qwook
So for the flipped/rotation code, you missed one last flag:

Code: Select all

                    if flipped_horiz then
                        if flipped_diag then
                            data.r = math.rad(90)
                        elseif flipped_verti then
                            data.sx = -1
                            data.sy = -1
                        else
                            data.sx = -1
                        end
                    elseif flipped_verti then
                        if flipped_diag then
                            data.r = math.rad(-90)
                        else
                            data.sy = -1
                        end
                    elseif flipped_diag then
                        data.r = math.rad(90)
                        data.sy = -1
                    end
the last one meaning they didn't flip horizontally and they didn't flip vertically, but they flipped diagnoally.

Re: Simple Tiled Implementation - STI v0.6.12

Posted: Fri Jan 31, 2014 1:36 pm
by Karai17
Oh, whoops! I'll patch this later today. Thanks for the heads up!

Edit: Fixed!

Re: Simple Tiled Implementation - STI v0.6.13

Posted: Sat Feb 01, 2014 11:10 pm
by elgruntox
Hey great library, quick question (maybe request):

Is there a way to get the properties on each tile when looping through a layer? I have a layer where I place all my in game objects in (player start position, enemy starting locations, etc) and it would be cool to be able to loop through the layers tiles and fetch the property for each tile. I noticed that in the map table the tilesets have what I'm talking about but its kinda useless to me as I cant see the location (x. y) of the tiles (I'm assuming this is just tileset metadata)

Re: Simple Tiled Implementation - STI v0.6.13

Posted: Sat Feb 01, 2014 11:48 pm
by Karai17
One way to do this is to create an object layer and give each object a name or properties, then do a nearest tile search to determine which tile it is on.

Another way is to create a tile layer with a tileset only used for meta data.

Finally, each layer should have a properties section that you could add metadata to.

Re: Simple Tiled Implementation - STI v0.6.13

Posted: Sun Feb 02, 2014 12:26 am
by elgruntox
Karai17 wrote:One way to do this is to create an object layer and give each object a name or properties, then do a nearest tile search to determine which tile it is on.

Another way is to create a tile layer with a tileset only used for meta data.

Finally, each layer should have a properties section that you could add metadata to.
Okay I've done this, I guess the issue seems to be that some of my tiles that have properties aren't being seen via STI as having a property. I have a property in one tileset on a tile that I can see the property's of fine when I inspect `map.tiles` but a tile in a different tileset, which has a property of `object:player` isn't visible at all. In its tileset entry though I can see the tile with the property and the key and value are set fine, it just doesnt seem to appear in map.tiles. Is there something I'm missing here? I just need the value and x/y of all tiles with the property key of "object" basically.

Re: Simple Tiled Implementation - STI v0.6.13

Posted: Sun Feb 02, 2014 12:32 am
by Karai17
Are you using the latest version of STI? There was a bug a couple versions back where I wasn't properly saving tile properties.

It's also worth noting that each tile as a unique ID, so the first tile in the second tileset isn't going to be "1", it may be "1025" or whatever. Are you sure you're looking at the right tiles?

If you can't get it to work, can you please post a .love and tell me which tiles you're looking at so I can debug it? Thanks!

Re: Simple Tiled Implementation - STI v0.6.13

Posted: Mon Feb 03, 2014 12:19 am
by qwook
tile properties set like so:
Image

still aren't being read properly, especially when there is more than one tileset.

the gid you calculate is not the real id, and I had to reimplement my code:
Image

I looked through the source code and I speculate it's because you start from "1" but the tile indexing in the map starts from "0".
I haven't tried yet, though

Re: Simple Tiled Implementation - STI v0.6.14

Posted: Mon Feb 03, 2014 2:19 am
by Karai17
The 0 tile is an empty tile (filler data), the actual tiles start from 1. My GIDs are 100% accurate, I've tested them thoroughly.

I fixed the problem, though. The tile properties section of the map uses local tile numbers, not the global tiles. I overlooked this.

Re: Simple Tiled Implementation - STI v0.6.14

Posted: Mon Feb 03, 2014 5:30 pm
by qwook
ah, makes sense.
thanks for maintaining this man, our game really depends on it :megagrin:

Re: Simple Tiled Implementation - STI v0.6.14

Posted: Mon Feb 03, 2014 7:22 pm
by Karai17
Thank YOU for taking interest in my work! Let me know if you find any more bugs :D