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?

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

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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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

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.

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

1
2
3
4
5
6
7
8
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

Could you email me your project so I could have a quick look at it?

views:1636 update:2011/10/13 16:30:09
corona forums © 2003-2011