Hi,
Is there a way to move an object to another layer?
thanks
Hi,
Is there a way to move an object to another layer?
thanks
As image shows, click on object, and use the ‘move to layer’ icon to choose which layer to move it to
sorry I meant in code in corona. should’ve mentioned that
I see, yes a little more complicated
Try this (not tested that well), but it moves an object called “text” from layer “Layer1” to “Layer2”
local myLevel = {} myLevel= LD\_Loader:new() myLevel:loadLevel("Level01") local obj = myLevel:getLayerObject("Layer1","text") print (obj.layerName) local function moveToLayer(obj,layerTo) for k, v in pairs (myLevel.level.layers[obj.layerName].objects) do if obj.name == v.name then --update LDX internal collections table.remove(myLevel.level.layers[obj.layerName].objects,k) table.insert(myLevel.level.layers[layerTo].objects,v) --move to new display group myLevel.level.layers[layerTo].view:insert(obj.view) --change reference on object obj.layerName = layerTo break end end end moveToLayer(obj,"Layer2") print (obj.layerName)
this is great! Thank you very much!
As image shows, click on object, and use the ‘move to layer’ icon to choose which layer to move it to
sorry I meant in code in corona. should’ve mentioned that
I see, yes a little more complicated
Try this (not tested that well), but it moves an object called “text” from layer “Layer1” to “Layer2”
local myLevel = {} myLevel= LD\_Loader:new() myLevel:loadLevel("Level01") local obj = myLevel:getLayerObject("Layer1","text") print (obj.layerName) local function moveToLayer(obj,layerTo) for k, v in pairs (myLevel.level.layers[obj.layerName].objects) do if obj.name == v.name then --update LDX internal collections table.remove(myLevel.level.layers[obj.layerName].objects,k) table.insert(myLevel.level.layers[layerTo].objects,v) --move to new display group myLevel.level.layers[layerTo].view:insert(obj.view) --change reference on object obj.layerName = layerTo break end end end moveToLayer(obj,"Layer2") print (obj.layerName)
this is great! Thank you very much!