Help with Physics Platformer camera


I downloaded sample project Physics Platformer. Then I try to extend it. But camera goes wrong after some time. Help me please

1 Comment

Hi Karam and welcome to the forum

I think you have a very good point there, and I must update the example project. Currently the character for the physics platformer includes some code to set the camera bounds.

This is some code that we used when we were building a larger level, and wanted to have different camera constraints for different parts of the level. You can simply delete this code now (and perhaps replace it with something that suits your needs).

Select the main character, and the go to its onAddToScene function. You'll see these lines

this.xBoundLimits = [4000, 7580, 8860, 12150, 999999];
this.yMaxBounds = [100, 2150, 1400, 350, -100]; 

These define the camera limits on Y corresponding to different sections of the level. I would replace it with this:

this.xBoundLimits = [999999];
this.yMaxBounds = [100]; 

This basically means: as long as the character's x position is less than 999999, make sure that the camera's Y position is never less than 100. You can change those numbers to whatever you like, and add more "sections" for your level as you see fit.

Post a reply
Add Attachment
Submit Reply
Login to Reply