Page 2 of 2

Re: Hardon Collider not detecting collision

Posted: Mon Jun 11, 2012 3:19 pm
by munchor
Yeah, it works for me too, now even stranger :S I'm really confused, what a mystery.

Re: Hardon Collider not detecting collision

Posted: Mon Jun 11, 2012 3:51 pm
by Kadoba
maps[1].tl["ground"] isn't nil for me. How are you testing it?

Re: Hardon Collider not detecting collision

Posted: Mon Jun 11, 2012 4:30 pm
by munchor
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

Posted: Tue Jun 12, 2012 2:34 pm
by Kadoba
map[1].tl["ground"].tileData.iterate is there for me. Can you upload another .love?

Re: Hardon Collider not detecting collision

Posted: Tue Jun 12, 2012 3:20 pm
by munchor
Kadoba wrote:map[1].tl["ground"].tileData.iterate() works for me. Can you upload another .love?
I forgot .tileData.

Attached is a .love.

Code: Select all

ERROR: AdvTiledLoader/Grid.lua:57: attempt to index local 'self' (a nil value)
I'm getting that error, and it is being reported somewhere in this function:

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
Thanks in advance!

Re: Hardon Collider not detecting collision

Posted: Tue Jun 12, 2012 3:51 pm
by Kadoba
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

Posted: Tue Jun 12, 2012 3:59 pm
by munchor
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
Thank you, that fixed it :) However, "if tile and tile.properties.solid then" is never being called.

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>
There's .tmx file, attached is yet another .love.

Re: Hardon Collider not detecting collision

Posted: Tue Jun 12, 2012 4:19 pm
by Kadoba
You had the solid property in your layer set to 1, but not in the individual tiles.

Re: Hardon Collider not detecting collision

Posted: Tue Jun 12, 2012 4:26 pm
by munchor
Kadoba wrote:You had the solid property in your layer set to 1, but not in the individual tiles.
Ah, I get it. I managed to make it work. I'll just use "layer.properties.solid", instead of setting each tile to "solid".

Thank you tons for the help!

Re: Hardon Collider not detecting collision

Posted: Fri Aug 31, 2012 10:27 pm
by paclito
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