Help me understand screen vs. actual locations

Lets say I have a display group (my level) which is 2048 x 1024 pixels in size. I know my view port is 1024x768 pixels.

I’m trying to use Graham Ransom’s Camera.lua file to manage my view into the world. The problem is I’m using touch-drag to move the player. Graham’s camera wants to keep the player centered which doesn’t do well with touch drag.

I’m trying to make it so that it won’t start scrolling the background until you near the bounderies of the viewport.

The problem is I don’t know how to map the various numbers I get back (player.x, player.y, event.x, event.y, etc. to screen

I think it has something to do with contentToLocal() but I’m not all that sure how to do this.

I want to know when the player reaches 80% of the screen width and then scroll the camera under the player (as well as 20% the other way and both up and down).

and then move the camera at the same rate the player is moving keeping the camera positioned at the 80/20 point rather than the center.

Any advice? [import]uid: 19626 topic_id: 23038 reply_id: 323038[/import]

Anyone? [import]uid: 19626 topic_id: 23038 reply_id: 92293[/import]

I haven’t used the camera.lua class, but this is how I do it. I check to see if the player is past a certain point in the original view and if it is, I make sure the camera follows the players location with the offset value given.

[lua]local screen = display.newGroup()
local circle = display.newCircle(0,0,40)
screen:insert(circle)

Runtime:addEventListener(‘enterFrame’,function(event)

–i only want to follow the circle horizontally if the x value is 400
if circle.x > 400 then
screen.x = -circle.x +400
end

–i only want to follow the circle vertically if the y value is less than

if circle.y > 300 then
screen.y = circle.y + 300
end

end)[/lua]

You may need to do something like this inside of the camera.lua file

Let me know if this helps. [import]uid: 49520 topic_id: 23038 reply_id: 92378[/import]