Hi, I was going through the perspective plugin in the marketplace. I found these lines of code
function view:add(obj, lyr, isFocus) local lyr = lyr or 4 layers[lyr]:insert(obj) obj.\_perspectiveLayer = lyr if isFocus then view:setFocus(obj) end -- Move an object to a layer function obj:toLayer(newLayer) if layer[newLayer] then layer[newLayer]:insert(obj) obj.\_perspectiveLayer = newLayer end end --Move an object back a layer function obj:back() if layer[obj.\_perspectiveLayer + 1] then layer[obj.\_perspectiveLayer + 1]:insert(obj) obj.\_perspectiveLayer = obj.layer + 1 end end --Moves an object forwards a layer function obj:forward() if layer[obj.\_perspectiveLayer - 1] then layer[obj.\_perspectiveLayer - 1]:insert(obj) obj.\_perspectiveLayer = obj.layer - 1 end end --Moves an object to the very front of the camera function obj:toCameraFront() layer[1]:insert(obj) obj.\_perspectiveLayer = 1 obj:toFront() end --Moves an object to the very back of the camera function obj:toCameraBack() layer[#layers]:insert(obj) obj.\_perspectiveLayer = #layers obj:toBack() end end
I can call the add function as usual using:
local camera = require("perspective").createView local rect = display.newRect(100,100, 50,50) camera:add(rect,4)
But how do i go about call the obj:toLayer() in the function view:add()
i tried few things like camera:add:rect:toLayer(5). But i’m not sure.