Camera assistance


(Nate ) #1

Hey guys! I have what I think is a simple camera question. It has been some time since I have used a camera but I am looking to have the camera follow the player but only once they reach the edge of the screen on the Y axis. The size of the stage is 640x480 this is the code that I have, the camera does not move at all. When I place a 200 in where the 480 is, it moves but not when I want it to. The character is 64x64 pixels.

FP.camera.y = (this.y - (FP.halfHeight - 64));
FP.camera.y = FP.clamp(FP.camera.y, 0, (480 - FP.height));

Thanks guys!


Parametrized camera follow snippet
(azrafe7) #2
if (y < FP.camera.y + height) FP.camera.y = y - height;
else if (y > FP.camera.y + FP.height - height) FP.camera.y = y - FP.height + height;

Scrolling affects collision?
(Nate ) #3

Seems to have worked wonderfully! Thank you azrafe7!