1 decade ago by Jon123
I have been basing my game on the JumpNRun example and have been trying to extend the level platform width.
After travelling a while, the camera stops following the player and allows it to walk off the screen. This is my camera code:
This is repeated in the same file, as like the JumpNRun example, there is an embedded class in the main class.
Please ask if more code is necessary. Thanks,
After travelling a while, the camera stops following the player and allows it to walk off the screen. This is my camera code:
setupCamera: function() { // Set up the camera. The camera's center is at a third of the screen // size, i.e. somewhat shift left and up. Damping is set to 3px. this.camera = new ig.Camera( ig.system.width/3, ig.system.height/3, 3 ); // The camera's trap (the deadzone in which the player can move with the // camera staying fixed) is set to according to the screen size as well. this.camera.trap.size.x = ig.system.width/5; this.camera.trap.size.y = ig.system.height/3; // The lookahead always shifts the camera in walking position; you can // set it to 0 to disable. this.camera.lookAhead.x = ig.system.width/6; // Set camera's screen bounds and reposition the trap on the player this.camera.max.x = this.collisionMap.pxWidth - ig.system.width; this.camera.max.y = this.collisionMap.pxHeight - ig.system.height; this.camera.set( this.player ); },
This is repeated in the same file, as like the JumpNRun example, there is an embedded class in the main class.
Please ask if more code is necessary. Thanks,