espace

how do you do this effect ?

Recommended Posts

hi,

i would have this effect like my capture screen. the square when it move have two ghost squares with different opacity.

But when it is stopped, the ghost squares are just beneath the square.

I have try this with a particle emitter + update but after trying a lot of parameters, I can not seem to have the desired effect.

have you a soluce for me ?

 

	this.ghost_player = game.add.emitter(this.x, this.y-50, 200)
	this.ghost_player.makeParticles("rect")
	this.ghost_player.minParticleSpeed.setTo(-0,-0)
	this.ghost_player.maxParticleSpeed.setTo(0,0)
	this.ghost_player.setAlpha(.1, .2)
	this.ghost_player.minParticleScale = 1
	this.ghost_player.maxParticleScale = 1
	this.ghost_player.minRotation = 0
	this.ghost_player.maxRotation = 0
	this.ghost_player.on=true
	this.ghost_player.start(true,8000, 200)

first.prototype.update = function() {
	this.ghost_player.y=this.y
	this.ghost_player.x=this.x
}

 

example.png

Share this post


Link to post
Share on other sites

Conceptually I'd want to model this using streams, your movement code becomes an emitter that emits positions (an emitter can be modelled as a stream very easily), I'd then keep track of a 'window' into the stream that tracks the last three triggers, most stream libraries will have methods to handle this for you. You move your 3 sprites based on the last 3 positions emitted from the stream, although as your stream only emits on movement this would not actually account for when you stop moving because when you stop moving you stop emitting so you'd have to handle that case, which could get tricky to do cleanly.

An alternative is that your main object 'drops' child objects (particles?) as it moves, these children are short lived and maybe very quickly move through a life cycle such that they begin full opacity and within a couple of ticks drop to 0 opacity and then get destroyed. A particle emitter system can probably be configured to do this as most particle systems work by creating particles, running updates on them and destroying them when some condition is met (often recycling to try and get some optimisation), which is exactly what you want.

Share this post


Link to post
Share on other sites

thanks for your advice.

 

finally i use particle with this paramater, it is whait i'm expecting

	this.ghost_player = game.add.emitter(this.x, this.y-25, 3)
	this.ghost_player.makeParticles("rect_l")
	this.ghost_player.setXSpeed(0,0)
	this.ghost_player.setYSpeed(0,0)
	this.ghost_player.minParticleAlpha=.2
	this.ghost_player.minParticleScale = 1
	this.ghost_player.maxParticleScale = 1
	this.ghost_player.minRotation = 0
	this.ghost_player.maxRotation = 0
	this.ghost_player.on=true
	this.ghost_player.start(true,20,20)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.