I need help -- cameras, touch-drag and physics not playing nice together.

I’m working a game, which can best be described as a platformer. I have maps that are longer and taller than the viewport and I want my player to freely move around the screen, of course stopping when colliding with something they can’t pickup or move and picking up and moving the things they can. All and all, its done and working except for one small requirement problem. The player is moved by touching and dragging. Again, that’s mostly working.
Here is the problem though… Lets say the player is at 100,100 and I tap and drag to 1000,200 (assume iPad screen dimensions) and my world is say 3000 pixels long.

Using Graham Ransom’s Camera module adapted from Lime, for the first 1/3 of the move, the player stays right under the finger where it belongs. during the middle 1/3 of the move, the finger as it approaches the right side of the screen and the player get out of sync. This is because the camera is moving the background X pixels left and slowly working the player to the center of the screen so basically until the player makes it until the end of the level is on the screen, the camera is going to move the background more than it will the player.

Of course, your finger eventually runs out of real-estate to do the touch drag anyway and it creates some very un-smooth game play. You have to keep stopping the touch drag and re-aquiring the player by touching on it again and while you’re in the scroll range of the camera you quickly get out of sync again.

so I thought about dumping the camera in favor of just moving the level based on where the player was, i.e. roll my own camera that would move the background when the player was closer to the edges, but to do that, I have to take the player out of the display group that has all my collidables and that will break physics.

I thought about a separate hit box that moved with the player, but the moment I put it into the group, I run into problems mapping the player x,y to the hitbox and world x,y’s.

I need someone smarter than me to help me figure this out.

And to add some fun to the problem, if I run into something, since I’m dragging the event.x and event.y if far enough away from the player can cause the player to teleport through things. I had this fixed by stopping movement, but in doing so the player can’t reverse direction without lifting a finger to end the event and re-touching.

In the words of Professor Backwards: Pleh! Pleh!
[import]uid: 19626 topic_id: 22752 reply_id: 322752[/import]