Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

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:

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,

1 decade ago by Jon123

I've just had a thought and will try it out when I get a chance, but maybe there is confusion between the two "setUpCamera" functions.

I have adapted the JumpNRun embedded class to allow the player to move around, instead of pressing any key to continue. I therefore had to have a camera following the player.

Since the camera is already set up, maybe when the larger level loads, the camera still thinks the boundaries are what they were with the embedded class?

1 decade ago by Jon123

Yep that was the issue, easy fix.. Phew!
Page 1 of 1
« first « previous next › last »