Constructor

@:value({ gravity : 0.0, friction : 0.95, tension : 0.1, retainVelocity : false })new(sprite:FlxSprite, retainVelocity:Bool = false, tension:Float = 0.1, friction:Float = 0.95, gravity:Float = 0.0, ?offset:FlxPoint)

Adds a spring between the mouse and a FlxSprite

Parameters:

sprite

The FlxSprite to which this spring is attached

retainVelocity

True to retain the velocity of the spring when the mouse is released, or false to clear it

tension

The tension of the spring, smaller numbers create springs closer to the mouse pointer

friction

The friction applied to the spring as it moves

gravity

The constant downward force on the sprite (A negative value pulls up!)

offset

The anchor point of the sprite, relative to its position, If null, the sprite's origin is used. Note: A copy of the passed in point is used.

Variables

friction:Float

The friction applied to the spring as it moves

gravity:Float

The constant downward force on the sprite (A negative value pulls up!)

offset:FlxPoint

The anchor point of the sprite, relative to its position, If null, the sprite's origin is used

retainVelocity:Bool

Whether to retain the velocity of the spring when the mouse is released. If false, it's cleared on release

tension:Float

The tension of the spring, smaller numbers create springs closer to the mouse pointer

Methods

reset():Void

Resets the internal spring physics

update(elapsed:Float):Void

Updates the spring physics and repositions the sprite