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 paulh

ay quick suggestions on how to override an entities draw method to easily make trails?

1 decade ago by Graphikos

What do you mean by trails? Footprints or something?

1 decade ago by jswart

If you mean 'trail' as in footprints, or the path something took you will have to change background tiles, or make a new layer above the current map but below the entities with 'footprint' tiles.

If you main 'shadow' or 'ghost' image. Like the blur behind a character as it moves quickly, etc. I would do this in the AnimationSheet.

The latter is easier than the former.

1 decade ago by Graphikos

Well you could simply spawn entities for each of the footprints that would disappear over time and kill. No reason to get all complicated with the background tiles or anything like that. The main thing you'll have to work with is position (based on entity), spawn rate (aka only when entity moves so far) and orientation of the trail spawn (based on entity).

/><br />
<br />
Of course if you want to do more like a blurred trail or something you can look into like particle emmiters and whatnot.  <a href= Google comes up with a fair amount of examples on what can be done.

1 decade ago by quidmonkey

This is how I did it:

trail: [],	//trail
trailers: 5,	//number of trailing images

init: function( x, y, settings ){
	this.parent( x, y, settings );
	//build trail array
	for( var i = 0; i < this.trailers; i++ ){
		this.trail.push( this.pos );
	}
},

draw: function(){
	//draw trailers
	var alpha = this.currentAnim.alpha;
	for( var i = 0; i < this.trailers; i++ ){
		this.currentAnim.alpha = i.map( 0, this.trailers, 0.1, 1 );
		this.currentAnim.draw(
			this.trail[i].x - this.offset.x - ig.game._rscreen.x,
			this.trail[i].y - this.offset.y - ig.game._rscreen.y
		);		
	}
	this.currentAnim.alpha = alpha;
	this.parent();
},

update: function(){
	this.parent();
	//remove first trail element, push on new element
	this.trail.shift();
	this.trail.push( this.last );
}

1 decade ago by paulh

Thank you again quid!
Page 1 of 1
« first « previous next › last »