Hardon Collider not detecting collision
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Hardon Collider not detecting collision
Yeah, it works for me too, now even stranger :S I'm really confused, what a mystery.
- Attachments
-
- stack-tile.love
- (61.15 KiB) Downloaded 154 times
Re: Hardon Collider not detecting collision
maps[1].tl["ground"] isn't nil for me. How are you testing it?
Re: Hardon Collider not detecting collision
Neither to me, but I get this:
Code: Select all
main.lua:72: attempt to call method 'iterate' (a nil value)
Re: Hardon Collider not detecting collision
map[1].tl["ground"].tileData.iterate is there for me. Can you upload another .love?
Last edited by Kadoba on Tue Jun 12, 2012 3:46 pm, edited 1 time in total.
Re: Hardon Collider not detecting collision
I forgot .tileData.Kadoba wrote:map[1].tl["ground"].tileData.iterate() works for me. Can you upload another .love?
Attached is a .love.
Code: Select all
ERROR: AdvTiledLoader/Grid.lua:57: attempt to index local 'self' (a nil value)
Code: Select all
function get_solid_tiles(map)
local collidable_tiles = {}
local layer = map.tl["ground"]
for tileX, tileY, tile in layer.tileData.iterate() do
if tile and tile.properties.solid then
local ctile = collider:addRectangle((tileX - 1) * 16, (tileY - 1) * 16, 16, 16)
ctile.type = "tile"
collider:addToGroup("tiles", ctile)
collider:setPassive(ctile)
table.insert(collidable_tiles, ctile)
end
end
print(#collidable_tiles)
end
Re: Hardon Collider not detecting collision
Iterate needs to be called using a colon instead of a period.
Code: Select all
function get_solid_tiles(map)
local collidable_tiles = {}
local layer = map.tl["ground"]
for tileX, tileY, tile in layer.tileData:iterate() do
if tile and tile.properties.solid then
local ctile = collider:addRectangle((tileX - 1) * 16, (tileY - 1) * 16, 16, 16)
ctile.type = "tile"
collider:addToGroup("tiles", ctile)
collider:setPassive(ctile)
table.insert(collidable_tiles, ctile)
end
end
print(#collidable_tiles)
end
Re: Hardon Collider not detecting collision
Thank you, that fixed it However, "if tile and tile.properties.solid then" is never being called.Kadoba wrote:Iterate needs to be called using a colon instead of a period.
Code: Select all
function get_solid_tiles(map) local collidable_tiles = {} local layer = map.tl["ground"] for tileX, tileY, tile in layer.tileData:iterate() do if tile and tile.properties.solid then local ctile = collider:addRectangle((tileX - 1) * 16, (tileY - 1) * 16, 16, 16) ctile.type = "tile" collider:addToGroup("tiles", ctile) collider:setPassive(ctile) table.insert(collidable_tiles, ctile) end end print(#collidable_tiles) end
By this I mean, tile.properties.solid is always "nil". I am sure I have a tileset of tiles with the property "solid" set to "1".
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="26" height="24" tilewidth="25" tileheight="25">
<tileset firstgid="1" name="Tiles" tilewidth="25" tileheight="25">
<properties>
<property name="solid" value="1"/>
</properties>
<image source="tileset.png" width="50" height="50"/>
</tileset>
<layer name="ground" width="26" height="24">
<properties>
<property name="ground" value="1"/>
</properties>
<data encoding="base64" compression="zlib">
eJxjYWBgYKETJgYQqw6X3pFqDyWAWnFHrD20BoPZHnroITfuBqM9LEg0rcKNBY0mFRCyB11+qNuDTf1wsodcMGrPqD3I9tADAwBmFgIF
</data>
</layer>
</map>
- Attachments
-
- stack-tile.love
- (61.16 KiB) Downloaded 140 times
Re: Hardon Collider not detecting collision
You had the solid property in your layer set to 1, but not in the individual tiles.
Re: Hardon Collider not detecting collision
Ah, I get it. I managed to make it work. I'll just use "layer.properties.solid", instead of setting each tile to "solid".Kadoba wrote:You had the solid property in your layer set to 1, but not in the individual tiles.
Thank you tons for the help!
Re: Hardon Collider not detecting collision
I'm trying to get working this example but I'm not capable to get the player collide with the map. Can someone put a .love where we can see the player colliding with the map?
aaand
jejeje how can i get the point where the collide or collision is done... perhaps to put a flame on the correct side or some sparks ? crash!
sorry for my poor english
aaand
jejeje how can i get the point where the collide or collision is done... perhaps to put a flame on the correct side or some sparks ? crash!
sorry for my poor english
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot] and 12 guests