Skip to content

Commit

Permalink
Confetti now respects timestep
Browse files Browse the repository at this point in the history
  • Loading branch information
grapefrukt committed Nov 18, 2013
1 parent d299378 commit 6862332
Showing 1 changed file with 10 additions and 4 deletions.
Expand Up @@ -18,6 +18,7 @@ package com.grapefrukt.games.juicy.effects.particles {
private var _gfx:ConfettiParticleGfx;
private var _vectorX:Number;
private var _vectorY:Number;
private var _age:Number;

public function ConfettiParticle(lifespan:Number=2) {
super(lifespan);
Expand Down Expand Up @@ -46,14 +47,19 @@ package com.grapefrukt.games.juicy.effects.particles {
_gtween.proxy.rotation = Math.random() * 360;
//_gtween.proxy.alpha = 0;

_gfx.gotoAndPlay(int(Math.random() * _gfx.totalFrames));
_age = Math.random() * _gfx.totalFrames;

}

private function update(gt:GTween):void {
x += _vectorX / 100;
y += _vectorY / 100;
var timeDelta:Number = GTween.timeScaleAll;

_age += timeDelta;
_gfx.gotoAndPlay(1 + (int(_age) % _gfx.totalFrames - 1));

x += _vectorX / 100 * timeDelta;
y += _vectorY / 100 * timeDelta;

var timeDelta:Number = 1;
_vectorY += 10 * timeDelta;
_vectorX -= _vectorX * .05 * timeDelta;
_vectorY -= _vectorY * .05 * timeDelta;
Expand Down

0 comments on commit 6862332

Please sign in to comment.