Hi I’m just starting to get into using Corona/Lua, and I have been trying to get a camera set up to track a box around a map I’ve made. I used the Composer to make a basic background (sky picture with grass, grass has physics enabled and is static), and in code made a box and set it up with a touch joint. When I run it, all of this works fine.
I want to set a camera to follow the box around using the perspective library. I required the library, created a new camera, and added my box to it, then try to track it during the “did” section of scene:show but I can’t get it to follow the box.
Extra parts of code have been cut out (Touch joint function, etc.),
local perspective = require( "perspective" ) local cam = perspective.createView() function scene:create( event ) local sceneGroup = self.view local crate = display.newImageRect( "Pictures/crate.png", 90, 90 ) crate.x, crate.y = 160, -100 crate.rotation = 15 cam:add(crate, 1, true) function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then cam:setParallax( 1, .6 ) elseif phase == "did" then -- Called when the scene is now on screen cam:track() end end