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 Joncom

Is there a way to make a special kind of entity that's always above all other map layers, even if the entity layer is not the top one?

1 decade ago by dominic

You&039;d have to draw this entity yourself. Depending on what you want to do, you could either just draw an #ig.Image above all layers, or modify your entity a bit:

// In your Entity
init: function( x, y, settings ) {
	this.parent( x, y, settings );
	
	// save a reference to this entity on your game
	ig.game.specialEntity = this;
},

draw: function( reallyDraw ) {
	// Only draw when the 'reallyDraw' param is true, 
	// so it ignores the "normal" draw call
	if( reallyDraw ) {
		this.parent();
	}
}



// In your Game
draw: function() {
	// Draw all background maps and entities
	this.parent();
	
	// Call draw() on your special entity with the extra
	// parameter added
	this.specialEntity.draw( true );
}

1 decade ago by Joncom

Clever. Thanks, I will definitely use this.

1 decade ago by stahlmanDesign

This works well to draw only a special entity (like a button) on top of all other layers.

You might want this if for example you have a layer of texture that obscures your entities, like if they walk behind a wall or into a cave, but you want the button to appear on top of the texture layer.
Page 1 of 1
« first « previous next › last »