AK-Tween for Corona SDK

Current Version 0.4

AK-Tween is a Corona library I made for Predeterminite Tweening. This will help boost performance of your app if you have a lot of transitions that don't require runtime calculation (for example, character part animations). Library is available as-is, and comes with a benchmark app to test performance/ functionality. 11/14/2012 Note: The documentation (and library) are a work-in-progress. Please check back periodically :)

Documentation

AKtween:newTween()

Type: Function
Returns: tween
Syntax: AKtween:newTween( config )

Overview:
Defines a new tween, consisting of a table of parameter arrays and the tween's total frame count.

Parameters:
config: a table of property values including:

  • time: Number
    Specifies the duration of the tween in milliseconds (1000ms by default).
  • delay: Number
    Specifies a delay in milliseconds before the tween begins (0ms by default).
  • x: Number
    The x-distance displacement of the tween, relative to the object's x-position at time of implementation.
  • y: Number
    The y-distance displacement of the tween, relative to the object's y-position at time of implementation.
  • rotation: Number
    The rotation amount of the tween, relative to the object's rotation at time of implementation.
  • xScale: Number
    The final x-scaling value of the tween. NOTE: Currently, this always starts at xScale=1. Future implementation will use xScale={from:value, to:value}.
  • yScale: Number
    The final y-scaling value of the tween. NOTE: Currently, this always starts at yScale=1. Future implementation will use yScale={from:value, to:value}.
  • alpha: Number
    The final alpha value of the tween. NOTE: Currently, this always starts at alpha=1. Future implementation will use alpha={from:value, to:value}.
  • ease: String
    Specifies the easing function (default is linear). NOTE: Currently only supports "linear", "inQuad", and "outQuad".
  • onComplete: Table
    Specifies another table of parameters to tween immediately following the initial configuration (Note: see here to specify an onComplete function after playing the tween)

Example:

AKtween:append()

Type: Function
Returns: nothing
Syntax: AKtween:append( config )

Overview:
Appends additional parameter arrays to an existing tween. Parameters that aren't currently configured in the tween before appending will start at time=0, unless a delay is specified. If the parameter already exist, it will continue from its last array position

Parameters:
config: a table of property values including:

  • time: Number
    Specifies the duration of the tween in milliseconds (1000ms by default).
  • delay: Number
    Specifies a delay in milliseconds before the tween begins (0ms by default). The delay will only affect the parameters used in the in the same append statement.
  • x: Number
    The x-distance displacement of the tween, relative to the object's x-position at time of implementation.
  • y: Number
    The y-distance displacement of the tween, relative to the object's y-position at time of implementation.
  • rotation: Number
    The rotation amount of the tween, relative to the object's rotation at time of implementation.
  • xScale: Number
    The final x-scaling value of the tween. NOTE: Currently, this always starts at xScale=1. Future implementation will use xScale={from:value, to:value}.
  • yScale: Number
    The final y-scaling value of the tween. NOTE: Currently, this always starts at yScale=1. Future implementation will use yScale={from:value, to:value}.
  • alpha: Number
    The final alpha value of the tween. NOTE: Currently, this always starts at alpha=1. Future implementation will use alpha={from:value, to:value}.
  • ease: String
    Specifies the easing function (default is linear). NOTE: Currently only supports "linear", "inQuad", and "outQuad".
  • onComplete: Table
    Specifies another table of parameters to tween immediately following the initial configuration (Note: see here to specify an onComplete function after playing the tween)

Example:

AKtween:apply()

Type: Function
Returns: nothing
Syntax: AKtween:apply( object, name )

Overview:
Applies a tween to any Corona display object, and gives it a unique tween name. The object can then call :playTween() to play any tween applied to it.

Parameters:
object: any Corona display object, including images and sprites.
name: a unique name for the tween.

Example:

AKtween:playTween()

Type: Function
Returns: nothing
Syntax: object:playTween( name, config )

Overview:
Plays a tween applied to the display object.

Parameters:
name: the name of the tween to play
config: an optional table containing one or more of the following:

  • onComplete: Table
    Specifies a callback function that will occur at the end of the tween.
  • delay: Number
    Specifies a delay in milliseconds before the entire tween begins (0ms by default).
  • speed: Number
    Specifies the speed of the tween (only supports 0.5, 1, and 2).

Example:

AKtween:finishTween()

Type: Function
Returns: nothing
Syntax: object:finishTween()

Overview:
Prematurely ends the current object's tween.

Example:

Follow ArdentKid
Like ArdentKid
Plus ArdentKid