Re: Simple Tiled Implementation - STI v0.14.1.8
Posted: Mon Dec 28, 2015 2:41 am
Use object layers for that, not tile layers.
Ok, I changed my map to use object layer, it looks better. But I still have the same problem with removing objects from map at runtime. I ended up with following, but how would you do it better?Karai17 wrote:Use object layers for that, not tile layers.
Code: Select all
-- layer is called "objects"; item is the one to be removed (collected)
for k,v in pairs(self.map.layers.objects.objects) do
if v.id == item.id then
table.remove(self.map.layers.objects.objects, k)
end
end
self.map:setObjectSpriteBatches(self.map.layers.objects)
OK, but I still need to call `setObjectSpriteBatches`, right? Is this the correct way?Karai17 wrote:Use ipairs, it is way faster. Also make sure to remove the object from map.objects
Code: Select all
for k,v in ipairs(map.layers.objects.objects) do
if v.id == item.id then
table.remove(map.layers.objects.objects, k)
end
end
table.remove(map.objects, item.id)
map:setObjectSpriteBatches(map.layers.objects)
it is the layer, it is called "objects" so I guess it is ok. Thanks for your help!Karai17 wrote:Pass in the whole layer, not just the objects.
Rishavs wrote:Hi
I seem to have hit an issue with your lib.
For isometric Staggered map, it is only displaying 21, 21 tiles.
I am attaching the map i used.
my code is here
https://github.com/rishavs/RoguishLove/
and the file where all the map stuff happens is src/_state_Game.lua