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 beardedbuddha

Hey Forum,
I'm new to Impact and I'm building my first game. Of course it's a sidescroller.
I have a repeating background-layer with it's distance set to 2.
I'm sure I can somehow mod the background layer so that it only "moves" (relative to the foreground(main) layer / parallax effect) on the x-axis.
How would I go about doing this?

The situation is, that the background is supposed to be a city skyline in the distance and it looks kind of funky when the buildings move under water when the player goes to a lower platform.

Thanks in advance!
.BB

1 decade ago by dominic

Subclass the BackgroundMap and overwrite .setScreenPos() to ignore the y-axis:
BackgroundMapXScroll = ig.BackgroundMap.extend({
	setScreenPos: function( x, y ) {
		this.scroll.x = x / this.distance;
		// ignore y
	}
});

You&039;d then have to make sure that your #loadLevel() method (or whatever you use to create your backgroundMaps) uses this class for this one particular layer.


Or:
Inject some code in the BackgroundMap class that ignores the y scroll if it has a certain name. That's a bit hack-ish though :)
ig.BackgroundMap.inject({
	setScreenPos: function( x, y ) {
		this.scroll.x = x / this.distance;
		if( this.name !== 'CityBackground' ) {
			this.scroll.y = y / this.distance;
		}
	}
});

1 decade ago by beardedbuddha

Thanks for the reply Dominic and thanks for a fantastic engine.
This is exactly what I'm looking for!

I'll test it out as soon as I get home..!
Page 1 of 1
« first « previous next › last »