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 Ash_Blue

For the newer run and jump demo I wanted to use the camera plugin at a larger Canvas scale. When trying to do this you'll quickly notice the camera jitters when camera.set(entity) is called. After fiddling with the plugin a bit I found a fix.

Dominic, any chance you can get this fix into the demo so others don't run into this? Haven't tested it in the run'n jump demo but it seems to fix all the bugs I was seeing at a smaller scale size.

ig.Camera = ig.Class.extend({
    set: function( entity ) {
	this.trap.pos.x = entity.pos.x - this.trap.size.x / 2;
	this.trap.pos.y = entity.pos.y + entity.size.y - this.trap.size.y;

        this.pos.x = this.trap.pos.x - (ig.system.height / 2 - this.trap.size.x / 2);
        this.pos.y = this.trap.pos.y - (ig.system.height / 2 - this.trap.size.y / 2);
    }
});

1 decade ago by dominic

You're right! .set() didn't work correctly.

Theres a typo in your version though: ig.system.height is used instead of the width.

I ended up doing it a bit differently, still. The camera actually positions the trap on the screen with the offset.x/y, given in the constructor. This is not always ig.system.width/2 - e.g. the Jump'n'Run uses ig.system.width/3 to position the trap more to the left of the screen, because you're mostly walking right.

My fixed version:
    set: function( entity ) {
		this.trap.pos.x = entity.pos.x - this.trap.size.x / 2;
		this.trap.pos.y = entity.pos.y + entity.size.y - this.trap.size.y;

        this.pos.x = this.trap.pos.x - this.offset.x;
        this.pos.y = this.trap.pos.y - this.offset.y;
		this.currentLookAhead.x = 0;
		this.currentLookAhead.y = 0;
    },

I also updated the Jump'n'Run example ZIP. Thanks for reporting!

1 decade ago by Ash_Blue

Np, and thank you for mentioning the typo. Thought my screen was nudging off on the x axis a bit at level load.
Page 1 of 1
« first « previous next › last »