69 lines
1.5 KiB
ActionScript
69 lines
1.5 KiB
ActionScript
package org.flixel
|
|
{
|
|
public class FlxParticle extends FlxSprite
|
|
{
|
|
|
|
public var lifespan:Number;
|
|
|
|
public var friction:Number;
|
|
|
|
public function FlxParticle()
|
|
{
|
|
super();
|
|
this.lifespan = 0;
|
|
this.friction = 500;
|
|
}
|
|
|
|
override public function update() : void
|
|
{
|
|
if(this.lifespan <= 0)
|
|
{
|
|
return;
|
|
}
|
|
this.lifespan -= FlxG.elapsed;
|
|
if(this.lifespan <= 0)
|
|
{
|
|
kill();
|
|
}
|
|
if(touching)
|
|
{
|
|
if(angularVelocity != 0)
|
|
{
|
|
angularVelocity = -angularVelocity;
|
|
}
|
|
}
|
|
if(acceleration.y > 0)
|
|
{
|
|
if(touching & FLOOR)
|
|
{
|
|
drag.x = this.friction;
|
|
if(!(wasTouching & FLOOR))
|
|
{
|
|
if(velocity.y < -elasticity * 10)
|
|
{
|
|
if(angularVelocity != 0)
|
|
{
|
|
angularVelocity *= -elasticity;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
velocity.y = 0;
|
|
angularVelocity = 0;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
drag.x = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function onEmit() : void
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|