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 city41

Hey guys,

I bought Impact about a week ago and am loving it. My game is already amazingly far along.

I've been exploring ideas on how to make a HUD. It seems like the most common approach is to use draw calls where you take ig.game.screen.x/y into account to keep things in a fixed place.

I've also found just creating a foreground layer in WM and setting its distance to a very large number, like 999999, fixes it in place. Technically it is "moving", but at such a small amount it won't move around by even one pixel during gameplay. Then you can just use standard entities, animations, etc, and even design your HUD in WM with this approach.

Has anyone tried this? Anyone hit any weird issues with this approach? I like how it takes advantage of impact itself and still lets me use animations and the like. It seems a lot of HUDs end up dropping down to canvas calls , which I'm trying to avoid.

1 decade ago by city41

dur, you can only put tiles on a foreground layer, not entities. Although tiles could work, entities are much better. So I made the concept of a "fixed" entity


ig.module('game.plugins.fixed-entity')
.requires('impact.entity')
.defines(function() {
	ig.Entity.inject({
		init: function(x, y, settings) {
			this.parent(x, y, settings);

			if(this.fixed) {
				this.initialPos = ig.copy(this.pos);
			}
		},

		draw: function() {
			if(this.fixed) {
				this.pos.x = this.initialPos.x + ig.game.screen.x;
				this.pos.y = this.initialPos.y + ig.game.screen.y;
			}
			this.parent();
		}
	});
});

Now if an entity has the key fixed=true, they are always fixed to the window. This gets me all the benefits I was hoping for, a HUD made out of standard entities, animation usage, etc.
Page 1 of 1
« first « previous next › last »