Hiding all the tiles in a layer

Graham,

I’m using a tile layer to ‘draw’ some paths for my enemies to follow which I’ll refer to in code, i.e. check properties in the path tiles. I’m using a single opaque tile to do this in a separate tile layer.

The tiles show on my map when the map loads, why doesn’t this hide them?

 local enemyPath = map:getTileLayer("Enemypaths")  
 enemyPath:hide()  

Also is this the best approach, i.e. will I still be able to check for the tiles and reference their properties if they are hidden?

Thanks four your help,

Cheers!

Rob

[import]uid: 12431 topic_id: 7904 reply_id: 307904[/import]

Your code does work as long as you create the visual first.

Here it is in action with a loop to show tile id’s for that tile layer (even though they are hidden)

  
display.setStatusBar( display.HiddenStatusBar )  
  
lime = require("lime")  
  
local map = lime.loadMap("Test.tmx")  
  
visual = lime.createVisual(map)  
  
local enemyPath = map:getTileLayer("Enemypaths")  
 enemyPath:hide()  
  
   
-- If layer exists  
if(enemyPath) then  
  
 -- Get the tiles   
 local tiles = enemyPath.tiles  
  
 -- Ensure tiles is not nil  
 if(tiles) then  
  
 -- Loop through tiles   
 for i=1, #tiles, 1 do  
  
 -- print gid  
 print("Tile:" .. i .. " id:" .. tiles[i].gid)  
  
 end  
 end  
end  
  

[import]uid: 8366 topic_id: 7904 reply_id: 28069[/import]

Thanks evs for beating me to it. I was about to post that it should work fine but then saw your reply.

@technohead2000 If you are still having issues just post again. [import]uid: 5833 topic_id: 7904 reply_id: 28074[/import]

Thanks for your help. I’m afraid the following doesn’t work, this is my ‘constructor’ to build a map class:

  
function new(mapName)   
 local self = lime.loadMap("levelOneMap.tmx")   
 local visual = lime.createVisual(self)  
 local enemyPaths = self:getTileLayer("enemyPaths")  
 enemyPaths:hide()  
 print(enemyPaths.name)  
 return self  
end  
  

There are no errors and the print statement prints the layer name but the tiles aren’t hidden in the simulator.

[import]uid: 12431 topic_id: 7904 reply_id: 28183[/import]

Could you email me your project so I could have a quick look at it? [import]uid: 5833 topic_id: 7904 reply_id: 28198[/import]