********* Update (7/19/2016) **********
After 3 frustrating weeks of not being able to build a camera system like the one in Color Switch, I finally got it! The camera system I built follows the player only when the player is at the center, but doesn’t if it’s below it.
It took me at least twelve different variations and approximately 50 hours to get this to work. I almost felt like quitting my project because I couldn’t figure out why there was always a gap between the object and the center in my old code. But now I have it and the code is in my most recent post down below for anybody to use. The key here is to never give up and never give in.
May you all succeed in your projects.
-Dan
********* Previous Note (7/10/2016) **************
I am developing a camera movement that follows the player object only when its top touches the center line of the display. To visuathat the camera movement activates at the right moment, I have created a center line. But for whatever reason, the camera movement activates even before the object touches the center line, sometimes 2 to 4 pixels prior to reaching the center line. There’s usually a gap for a brief moment then it snaps to the midline.
Here’s the code:
----------------------------------------------------------------------------------------- -- Camera Module ----------------------------------------------------------------------------------------- local physics = require "physics" physics.start() physics.setDrawMode( "hybrid" ) physics.setGravity( 0, 20 ) local cX, cY = display.contentCenterX, display.contentCenterY local w, h = display.contentWidth, display.contentHeight local worldGrp = display.newGroup() worldGrp.anchorX = 0.5; worldGrp.anchorY = 1 worldGrp.x = cX; worldGrp.y = h local platform = display.newRect( worldGrp, 0, 0, w, 30) platform.anchorX = 0.5; platform.anchorY = 1; physics.addBody( platform, "static" , { bounce = 0 }) local boxJump = display.newRect( worldGrp, 0, -50 , 50, 50 ); boxJump.anchorY = 0; physics.addBody( boxJump, "dynamic", { density = 1, bounce = 0 }) boxJump.isFixedRotation = true local topHalfArea = display.newRect( cX, cY, w, h/2 ) topHalfArea.anchorY = 1 topHalfArea:setFillColor( 0, 0, 0, 0.5) local function jump( event ) if event.phase == "began" then boxJump:applyLinearImpulse( 0, -60, boxJump.x, boxJump.y ) end return true end Runtime:addEventListener( "touch", jump ) -- Dear Readers: The problem Starts Here \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* local camera = {} function camera.init( object ) object.startY = object.y end local centerLine = display.newRect( worldGrp, 0, -cY, w, 1) local center = -cY function camera.update( object, world ) -- Calculate how far we moved last frame local dY = object.y - object.startY --\*\* -- Save our new "last" position object.startY = object.y -- If object top reaches the midpoint of the display, then move the world if object.y \<= center then world.y = world.y - dY center = center + dY -- Update Center centerLine.y = center -- Update Center Line for Display end end camera.init( boxJump ) boxJump.enterFrame = function( self ) camera.update( self, worldGrp ) end Runtime:addEventListener( "enterFrame", boxJump )

Have you tried copying and pasting the code into the simulator to see if you get the same issue? I’m wondering if it’s just some glitch with my simulator that’s producing a gap and snap.