Hi guys,
I’m currently working on a top down aircraft shooter game and trying to implement my own camera function.
The basic function of this camera is that the screen will shift left / right when the plane is moving towards the edge of the screen.
Below is the code I’m currently using.
if (mainCharacter and mainCharacter.x \>= (displayWidth / 2 + 80)) then if (backgroundLayer.x \>= -20) then backgroundLayer.x = backgroundLayer.x - 0.2 cloudLayer.x = cloudLayer.x - 0.3 enemyobstaclesLayer.x = enemyobstaclesLayer.x - 0.3 end elseif (mainCharacter.x \<= (displayWidth / 2 - 80)) then if (backgroundLayer.x \<= 20) then backgroundLayer.x = backgroundLayer.x + 0.2 cloudLayer.x = cloudLayer.x - 0.3 enemyobstaclesLayer.x = enemyobstaclesLayer.x + 0.3 end end
The problem is that (as you might have guessed), shifting the position of a display group will cause the physics position to go off course. Is there any way around this?
I know there’s a Perspective Camera library available but I was unable to get it to work the way I want.
Any help is very much appreciated. Thanks in advance