Help with camera following player

Hello

I need some help with the camera following the player.

I used the egg breaker example to create this but I spent a long time trying to get it where i want it to with no success.

My goal is to have a character be able to navigate throughout the map and to have it stop at the edge of the map and all that fun stuff

I want it to be able to navigate a map like that.

-Boxie

(I made it plug and play just for you peoples - the red and green squares are just reference points in the map)

[code]


– main.lua


display.setStatusBar( display.HiddenStatusBar )
local screenW = display.contentWidth
local screenH = display.contentHeight
local game = display.newGroup();
game.x = 0
local square1 = display.newRect(0,0,60,60)
square1:setFillColor(0,255,0)
square1.x = 370
square1.y = 240
game:insert(square1)

local square2 = display.newRect(0,0,60,60)
square2:setFillColor(255,0,0)
square2.x = 100
square2.y = 240
game:insert(square2)
local point = display.newRect(0,0,20,20)
point:setFillColor(0,255,255)

point.x = 200
point.y = 300
local function movepoint(event)
if event.phase == “moved” then
point.x = event.x
point.y = event.y
end
end
Runtime:addEventListener(“touch”,movepoint)

local function border()
if point.x > 240 then
point.x = 240
end
if point.x < 80 then
point.x = 80
end
end
Runtime:addEventListener(“enterFrame”,border)
local function moveCamera()
if (point.x > 80 and point.x < 240) then

game.x = -point.x + 80

end
end

Runtime:addEventListener( “enterFrame”, moveCamera )

[import]uid: 113909 topic_id: 27151 reply_id: 327151[/import]