I need to make the camera always follow the character in my game. This is my code:
display.setStatusBar( display.HiddenStatusBar )
local fisica = require(“physics”)
physics.start()
physics.setDrawMode(“normal”)
physics.setGravity(0,9.8)
local fondo display.newImage (“sky2.bmp”)
local suelo = display.newImage (“suelo2.png”)
suelo:setReferencePoint( display.BottomLeftRferencePoint)
suelo.x, suelo.y = 160, 470
physics.addBody (suelo, “static”, {friction = 1.0, density=1.0, bounce=0,})
local paredIz = display.newRect( 0, 0, 1, 480 )
physics.addBody (paredIz, “static”, {friction = 1.0, density=1.0, bounce=0})
local ninja = display.newImage (“ninja.png”)
physics.addBody (ninja, {friction = 0.25, density=1, bounce=0.2, radius=37})
ninja.isFixedRotation = true
– Disparo tipo angry birds–
function moveNinja( event )
if event.phase == “began” then
display.getCurrentStage( ):setFocus(ninja)
elseif event.phase == “ended” then
ninja:applyLinearImpulse(event.xStart - event.x, event.yStart - event.y, ninja.x, ninja.y)
display.getCurrentStage( ):setFocus(nil)
end
end
ninja:addEventListener( “touch”, moveNinja)
I need to know how to create a group and how to make the camera always follow my character. Thanks