Hello @Caleb,
I am trying to implement the code you posted:
local function addObjectType(params)… and local objectType = {}…
Please correct me if I am wrong:
This code is responsible for finding all objects in object layer with the name “mySpecialObjectType”, and creating an object for it. This code will treat the culling by creating or removing the object when it goes offscreen, am I right?
I also saw that we call the function addObjectType(objectType) once per object, right?
Could you clarify the addObject Type function for me? Specially here:
for layer in map.objectLayers() do layer.addObjectListener("type", params.objectType, "drawn", buildObject) layer.addObjectListener("type", params.objectType, "erased", function(event) params.objects[event.object.builtObject] = nil params.remove(event.object.builtObject) end)
I saw in another post that we do not use a custom property for the type of the object in Tiled, we use the type field in the object.
I am using the portuguese version of Tiled, so should I change on the layer.addObjectListener(“type”) to layer.addObjectListener(“tipo”)?
I have tried to run this 2 functions with a piece of code from @painconfess but I am receiving the following error:
Attempt to call field ‘addObjectListener’(a nil value) stack traceback:
main.lua:105:in function ‘addObjectType’
main.lua:117:in main chunck
I wonder why I am receiving this error.
Once I can make this work, how can I access each object, to make all of them move? Should I create a function and inside it make a for loop with objects and make each of them move?
Sorry for the ammount of questions.
Thank you in advance and sorry for the long post