Here is my code with the correction “getObjectByName”
-------------------------------------------------------------------------------- -- Build Camera -------------------------------------------------------------------------------- local perspective = require( "perspective" ) -- Code Exchange library to manage camera view local camera = perspective.createView(3) -------------------------------------------------------------------------------- local target = display.newImage( "640x1136/target.png" ) target:scale( 0.25, 0.25 ) -- Shoot the object using a visible force vector function shootObject( event ) local t = event.target local phase = event.phase local startRotation --forward declaration if ( phase == "began" ) then display.getCurrentStage():setFocus( t ) t.isFocus = true target.x = t.x target.y = t.y startRotation = function() target.rotation = target.rotation + 4 end Runtime:addEventListener( "enterFrame", startRotation ) local showTarget = transition.to( target, { alpha=0.4, xScale=0.4, yScale=0.4, time=200 } ) myLine = nil elseif ( t.isFocus ) then if ( phase == "moved" ) then if ( myLine ) then myLine.parent:remove( myLine ) --erase previous line, if any end myLine = display.newLine( t.x,t.y, event.x,event.y ) myLine:setStrokeColor( 1, 1, 1, 50/255 ) myLine.strokeWidth = 15 elseif ( phase == "ended" or phase == "cancelled" ) then display.getCurrentStage():setFocus( nil ) t.isFocus = false local stopRotation = function() Runtime:removeEventListener( "enterFrame", startRotation ) end local hideTarget = transition.to( target, { alpha=0, xScale=1.0, yScale=1.0, time=200, onComplete=stopRotation } ) if ( myLine ) then myLine.parent:remove( myLine ) end local plasma = display.newImage( "640x1136/AlienHead.png" ) plasma.width = 80 plasma.height = 80 plasma.x = t.x plasma.y = t.y physics.addBody( plasma, { density=3, friction=1.0, bounce=.2, radius=40 } ) plasma:applyForce( 70\*(t.x - event.x), 70\*(t.y - event.y), t.x, t.y ) camera:add( plasma, 1 ) camera.damping = 10 --more fluid tracking local function trackPlasma( event ) if ( plasma.x \> 600 ) then camera:setFocus( plasma ) end end Runtime:addEventListener( 'enterFrame', trackPlasma ) end end return true --stop further propagation of touch event end local background = self:getObjectByName( "background" ) local gameGroup = self:getObjectByName( "gameGroup" ) local ufo = self:getObjectByName( "ufo" ) ufo:addEventListener( "touch", shootObject ) ------------------------------------------------------------ -- Camera code camera:setParallax( 1, 0.6 ) camera:add( background, 2 ) camera:add( gameGroup, 1 ) camera:setBounds( 0, 1480, 320, 320 ) --used to keep our view from going outside the background -- print( camera:layerCount() ) ------------------------------------------------------------