Ok so I have my player moving around the level/background and the camera following him. It seems to be working ok. However when I add another physics object (enemy) I have to put it in the same display group as my player right? Otherwise Box2D has a problem with detecting the collision. So I do this but now the object moves along with the camera and my player. This makes for a pretty silly game 
Have I gone about this the right way? I have two display groups. One for my background and another for my player. Or should I use one display group like the Eggbreaker example?
Game Info: The game is set under water and the player needs to be able to move in all directions following the user’s finger. The player will attack enemies on the surface and underwater.
I would be eternally grateful if someone could help.
Thanks
Here is my code
[lua]display.setStatusBar( display.HiddenStatusBar )
local physics = require(“physics”)
local gameUI = require(“gameUI”)
physics.start()
physics.setGravity(0,0)
physics.setDrawMode( “hybrid” )
local eventX = 0
local eventY = 0
–Create Display Groups
camera = display.newGroup()
camera.x = 0
camera.y = 0
movePlayer = display.newGroup()
movePlayer.x = 0
movePlayer.y = 0
–Draw Images and Load them into Display Group
local bg1 = display.newImageRect( “BG1_01.png” , 480, 320 )
bg1:setReferencePoint( display.CenterLeftReferencePoint )
bg1.x = 0; bg1.y = 160
camera:insert(bg1)
local bg2 = display.newImageRect( “BG2_02.png” , 480, 320 )
bg2:setReferencePoint( display.CenterLeftReferencePoint )
bg2.x = 480; bg2.y = 160
camera:insert(bg2)
local bg3 = display.newImageRect( “BG3_03.png” , 480, 320 )
bg3:setReferencePoint( display.CenterLeftReferencePoint )
bg3.x = 0; bg3.y = 480
camera:insert(bg3)
local bg4 = display.newImageRect( “BG4_04.png” , 480, 320 )
bg4:setReferencePoint( display.CenterLeftReferencePoint )
bg4.x = 480; bg4.y = 480
camera:insert(bg4)
–Draw Player and load into Display Group
player = display.newImage( “player.png” , 27, 27 )
player.xOrigin = 30; player.yOrigin = 50
physics.addBody(player, {bounce = 0.5, friction = 0.5, density = 2.0 })
player:setReferencePoint( display.CenterReferencePoint )
movePlayer:insert(player)
ghost = display.newImage(“ghost1.png”, 26, 26 )
ghost.x = 300; ghost.y = 200
physics.addBody(ghost, “dynamic”, {bounce = 0.5, friction = 0.5, density = 2.0 })
ghost:setReferencePoint( display.CenterReferencePoint )
camera:insert(ghost)
–Move Display Group to follow player
function moveCamera()
if(player.x > 80 and player.x < 960) then
camera.x = -player.x + 80
end
if(player.y > 0 and player.y < 720) then
camera.y = -player.y + 0
end
end
Runtime:addEventListener(“enterFrame”, moveCamera)
–Create Function to Drag Player
function stopP()
player:setLinearVelocity(0,0)
end
function moveP ()
if t then timer.cancel(t)
end
– PLayer speed
vmax = 60
dx = eventX-player.x
dy = eventY-player.y
ds = (dx*dx + dy*dy)
scalefactor = (vmax^2/ds)^0.5
vely = dy * scalefactor
velx = dx * scalefactor
traveltime = 500 * (ds^0.5) / vmax
player:setLinearVelocity(velx, vely)
t = timer.performWithDelay(traveltime, stopP)
end
function l ( event )
if(event.phase == “moved”) then
eventX = event.x
eventY = event.y
moveP ()
end
end
camera:addEventListener(“touch”, l)[/lua]
[import]uid: 26289 topic_id: 12614 reply_id: 312614[/import]