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 cjennison

I'm trying to move the background map so that I don't have to move the screen around for a Drop and Catch style game.

How do you move the background map?
I tried:
this.backgroundMaps[0].scroll.y--;

But that doesn't seem to do anything.

1 decade ago by Joncom

Wouldn't moving the background map still give the player the appearance that the screen is moving around? I'm not sure how doing this would help you...

There's another issue you might run in to if you choose this path. If you're using a collisionMap at all in your game, you're also going to have to shift that.

1 decade ago by dominic

The draw() method of your game calls .setScreenPos() on each layer with the game&039;s #.screen.x/y before drawing it. This overwrites your .scroll.y--.

I just would create the BackgroundMap in a way where it wont be put in the .backgroundMaps array and draw it myself instead. Something like this:

MyGame = ig.Game.extend({
	clearColor: null,
	mainBackground: null,
	
	init: function() {
		this.mainBackground = new ig.BackgroundMap( ... );
	},
	
	update: function() {
		// scroll 100px per second
		this.mainBackground.scroll.y -= ig.system.tick * 100;
	},
	
	draw: function() {
		this.mainBackground.draw();
		
		this.parent(); // draw all entities
	}
});
Page 1 of 1
« first « previous next › last »