Hi,
I created a level for my game. I am able to load the map, to call createVisual. That is working. But when I call createTileLayer it doesn’t.
Am I the only only having this problem ?
BR
Bruno [import]uid: 9097 topic_id: 10074 reply_id: 310074[/import]
The “createTileLayer” function is only for when you require to load a single specific layer, for most situations you won’t need to use it.
You should be fine with just:
[code]
local map = lime.loadMap( “map.tmx” )
lime.createVisual( map )
[/code] [import]uid: 5833 topic_id: 10074 reply_id: 36810[/import]
In fact I have game levels with 4 layers. On layer 1 and 2 I have static items. On layer 3 I have moving items driven by the game engine and on layer 4 I have static items. The aim of the fourth layer is to hide the moving items on some portions of the screen. So how do I do to access the display group corresponding to the third layer ?
I also have another question. I was playing with the tutorial about properties and I don’t understand why I need to create a visual of the map to access the properties associated with the tiles.
Thanks.
BR
Bruno
[import]uid: 9097 topic_id: 10074 reply_id: 36836[/import]
To get the visual of a certain layer you can do this:
local layer = map:getTileLayer( "layerName" )
local visual = layer:getVisual()
And as for properties, you don’t need to create the visual to get access to properties, but you do need to create it to use Property listeners. [import]uid: 5833 topic_id: 10074 reply_id: 36839[/import]
Ok. Thanks. I am going to have a look.
Bruno [import]uid: 9097 topic_id: 10074 reply_id: 36843[/import]
It is working except for the properties :
If I put that :
local layer = map:getTileLayer ( "StaticItems" ) ;
local list = layer:getTilesWithProperty ( "Type" ) ;
if list == nil then
print ( "Number of items = 0" ) ;
else
print ( "Number of items = "..#list ) ;
end
-- Create the visual
local visual = Lime.createVisual ( map ) ;
The result will be 0.
If I put that :
-- Create the visual
local visual = Lime.createVisual ( map ) ;
--
local layer = map:getTileLayer ( "StaticItems" ) ;
local list = layer:getTilesWithProperty ( "Type" ) ;
if list == nil then
print ( "Number of items = 0" ) ;
else
print ( "Number of items = "..#list ) ;
end
The result will be 3.
[import]uid: 9097 topic_id: 10074 reply_id: 36921[/import]
Ok thanks, I will look into that. Out of curiosity, is there any reason you need to have properties before creating the visual? [import]uid: 5833 topic_id: 10074 reply_id: 36943[/import]
I have two components : the GameEngine ( logic ) and the GraphicEngine ( graphics ). The GameEngine creates the GraphicEngine. I associate properties with the tiles ( such as Type=Obstacle ) so that I can build some kind of topography I will use with my PathFinding function.
Bruno [import]uid: 9097 topic_id: 10074 reply_id: 37022[/import]
OK cool, I will see if I can get the properties accessible before visual is created for the next version. [import]uid: 5833 topic_id: 10074 reply_id: 37141[/import]
Hi,
just to tell you I found a workaround :
_ I create the visual in my GameEngine but set the property isVisible to false.
_ Get all the properties to build the logic representation of the world.
_ Pass the map to my GraphicEngine.
_ Call getVisual function on the map and then set the isVisible property to true.
Et voila.
BR
Bruno from http://blueglutton.com [import]uid: 9097 topic_id: 10074 reply_id: 38226[/import]
Thank you for keeping me up to speed, I hope to have the issue solved for the next version so you won’t need to use the workaround but good to know just in case
[import]uid: 5833 topic_id: 10074 reply_id: 38248[/import]
You’re welcome.
Bruno from http://BlueGlutton.com [import]uid: 9097 topic_id: 10074 reply_id: 38259[/import]