Set the scale of particles like you would color or alpha?


(TaylorAnderson) #1

Hey, so I’m using the particle system in flashpunk and I want to make my particles become smaller as they disappear, to simulate a sort of dust effect when my character hits the ground after a jump. Is there any way to achieve this?


Flashpunk 2 BETA
Best Flame thrower emitter possible?
(Ultima2876) #2

Particles created from Emitters do not support scaling. The reason before was that they would have to be drawn using a transformation (as opposed to using the fast copyPixels method) thus eliminating most of the advantage of using an Emitter in the first place - however, newer versions of the library seem to have added support for rotation of Particles within an Emitter, so maybe it’s just an oversight that scaling has not also been added?

Anyhow, for now, until this feature is added, you’d probably be best just using entities with tweens for that kind of thing. They’re really not that much slower!


(TaylorAnderson) #3

Alright, I’ll look into doing that instead. Thanks!


(azrafe7) #4

As @Ultima2876 said scaling is not supported for performance reasons (although I haven’t tested it), but shouldn’t be hard to add in (following the same approach used by rotation - apply it only if enabled: see https://github.com/Draknek/FlashPunk/blob/master/net/flashpunk/graphics/Emitter.as#L136-L148).

Anyway, there’s an easier way to simulate scaled particles. Since they’re much similar to a spritesheet you can have different frames with scaled down version of the particle. I’m thinking of something like these (as used in the Pink demo):


(Ultima2876) #5

I agree with that, that’s probably a much more elegant solution than ‘reinventing the wheel’ with entities!