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 tyler

I wanted a entity to match its position to background layer that had a distance of 1.16. It looks like theres no official way to do this so I hacked this quickly. I just override the draw method with this:

	draw: function() {
		if( this.currentAnim ) {
			this.currentAnim.draw(
				(Math.round(this.pos.x) - this.offset.x - ig.game.screen.x)/this.distance,
				(Math.round(this.pos.y) - this.offset.y - ig.game.screen.y)/this.distance
			);
		}
	}

Its not perfect, but its as close as I can get. Im sure there is a better way, I just dont know what it is.

1 decade ago by tyler

Btw, this.distance is a prop you give your entity. In my case its set to 1.16

1 decade ago by stahlmanDesign

Seems like an elegant solution to me. You're saying it's not precise?

1 decade ago by tyler

It seem to screw with the animation a bit. It looks like is jumps though some frames too quickly.
Page 1 of 1
« first « previous next › last »