Motion Lib

Member Functions

AnimatorEngine:new

timeline |1 2 3 4 5 6 7 8 ------------------------------------------------------------------------------------max|
level 1  |-----animator-----|-----animator-----|-----animator-----|-----animator-----|-----animator-----|
level 2  |-----animator----------------|-----animator-----|-----animator-----|-----animator-----|
level 3  |-----animator----------------|-----animator-----|-----animator-----|----------------------animator-----|

渚嬪瓙瑙侊細
   1 涓や釜寮曟搸锛?
   --------------------------------------------------------
   NPL.load("(gl)script/ide/Motion/test/motion_test.lua");
   CommonCtrl.Motion.motion_test.show();
   --------------------------------------------------------
   engine 1 : 鍖呭惈3涓?levelManager锛屾瘡涓猯evelManager 鍖呭惈1涓?animator
   engine 2 : 鍖呭惈1涓?levelManager锛屾瘡涓猯evelManager 鍖呭惈3涓?animator

   2 涓€涓紩鎿庯細
   --------------------------------------------------------
   NPL.load("(gl)script/ide/Motion/test/motion_test_2.lua");
   CommonCtrl.Motion.motion_test_2.show();
   --------------------------------------------------------
   engine: 鍖呭惈4涓?levelManager锛屽墠3涓猯evelManager 姣忎釜鍖呭惈1涓?animator锛屾渶鍚?涓猯evelManager 鍖呭惈3涓?animator

------------------------------------------------------------
NPL.load("(gl)script/ide/Motion/AnimatorEngine.lua");
------------------------------------------------------------
]]

NPL.load("(gl)script/ide/commonlib.lua");
NPL.load("(gl)script/ide/math/bit.lua");
NPL.load("(gl)script/ide/LuaXML.lua");
NPL.load("(gl)script/ide/Motion/ITween.lua");
NPL.load("(gl)script/ide/Motion/AnimatorManager.lua"); 
NPL.load("(gl)script/ide/Motion/LayerManager.lua");
NPL.load("(gl)script/ide/Motion/RotateDirection.lua");
NPL.load("(gl)script/ide/Motion/Point.lua");
NPL.load("(gl)script/ide/Motion/Source.lua");
NPL.load("(gl)script/ide/Motion/CustomEase.lua");
NPL.load("(gl)script/ide/Motion/Keyframe.lua");
NPL.load("(gl)script/ide/Motion/Motion.lua");
 Leio: contact LiXizhi. This could randomly generate an error when loading an empty file. 
NPL.load("(gl)script/ide/Motion/BezierEase.lua");
NPL.load("(gl)script/ide/Motion/BezierSegment.lua");
NPL.load("(gl)script/ide/Motion/Animator.lua");
NPL.load("(gl)script/ide/Motion/DisplayObject.lua");
NPL.load("(gl)script/ide/Motion/Tweenables.lua");
NPL.load("(gl)script/ide/Motion/SimpleEase.lua");
NPL.load("(gl)script/ide/Motion/ColorTransform.lua");
NPL.load("(gl)script/ide/Motion/Color.lua");

local AnimatorEngine = {
   name = "",
   totalFrame = 1,
   _elapsedtime = 0,
   autoRewind = false,
   -- if this is 0, it will repeat infinitly. 
   repeatCount = 1,
   _isPlaying = false,
   _target = nil,
   _lastRenderedTime = -1,
   _time = 0,
   playCount = 0,
   framerate = 12,
   firstFrame = 0,
    --event
    --鍔ㄧ敾鍋滄锛屽苟杩斿洖鍒扮涓€甯?
    OnMotionStop = nil,
    --鍔ㄧ敾鍋滄锛屽仠姝㈠湪鏈€鍚庝竴甯?
    OnMotionEnd = nil,
    OnMotionStart = nil,
    OnTimeChange = nil,
    OnMotionRewind = nil,
    OnMotionPause = nil,
    OnMotionResume = nil,
    
    OnFail = nil,
    --
    animatorManager = nil,   
}
commonlib.setfield("CommonCtrl.Motion.AnimatorEngine",AnimatorEngine); local AnimatorPool={}; commonlib.setfield("CommonCtrl.Motion.AnimatorPool",AnimatorPool);

syntax

function AnimatorEngine:new(o)

parameters

o  

AnimatorEngine:doPause

Pauses the animation until you call the resume() method.

syntax

function AnimatorEngine:doPause()

AnimatorEngine:rewind

Sets Flash Player to the first frame of the animation. If the animation was playing, it continues playing from the first frame. If the animation was stopped, it remains stopped at the first frame.

syntax

function AnimatorEngine:rewind()

Member Functions

Animator.OnMotionEnd

event

syntax

function Animator.OnMotionEnd(layerManager)

parameters

layerManager  

Animator:Init

Creates an Animator object to apply the XML-based motion tween description to a display object.

  • param dataPath : motion xml path
  • param targetName : the name of ParaUIObject

syntax

function Animator:Init(dataPath,targetName)

parameters

dataPath motion xml path
targetName  

Animator:InitFromMotion

creates an animator object

  • param motionStr : motion xml string
  • param targetName : the name of ParaUIObject

syntax

function Animator:InitFromMotion(motionStr,targetName)

parameters

motionStr motion xml string
targetName  

Animator:GetMotion

The object that contains the motion tween properties for the animation.

syntax

function Animator:GetMotion()

Animator:isPlaying

Indicates whether the animation is currently playing.

syntax

function Animator:isPlaying()

Animator:GetTarget

The display object being animated. Any subclass of flash.display.DisplayObject can be used, such as a MovieClip, Sprite, or Bitmap.

syntax

function Animator:GetTarget()

Animator:GetTime

A zero-based integer that indicates and controls the time in the current animation. At the animation's first frame time is 0. If the animation has a duration of 10 frames, at the last frame time is 9.

syntax

function Animator:GetTime()

Animator:getTotalFrame

syntax

function Animator:getTotalFrame()

Animator:nextFrame

Advances Flash Player to the next frame in the animation sequence.

syntax

function Animator:nextFrame()

Animator:play

[[ /** * Begins the animation. Call the end() method * before you call the play() method to ensure that any previous * instance of the animation has ended before you start a new one. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword play, begin * @see #end() */ ]]

syntax

function Animator:play()

Animator:doEnd

[[ /** * Stops the animation and Flash Player goes immediately to the last frame in the animation sequence. * If the autoRewind property is set to true, Flash Player goes to the first * frame in the animation sequence. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword end, stop * @see #autoRewind */ ]]

syntax

function Animator:doEnd()

Animator:pause

Pauses the animation until you call the resume() method.

syntax

function Animator:pause()

Animator:resume

Resumes the animation after it has been paused by the pause() method.

syntax

function Animator:resume()

Animator:rewind

Sets Flash Player to the first frame of the animation. If the animation was playing, it continues playing from the first frame. If the animation was stopped, it remains stopped at the first frame.

syntax

function Animator:rewind()

Member Functions

AnimatorManager:new

timeline |1 2 3 4 5 6 7 8 ---------------------------------------------------------------------------max|
level 1  |-----animator-----|-----animator-----|-----animator-----|-----animator-----|-----animator-----|
level 2  |-----animator----------------|-----animator-----|-----animator-----|-----animator-----|

------------------------------------------------------------
NPL.load("(gl)script/ide/Motion/AnimatorManager.lua");
------------------------------------------------------------
]]

local MotionResource = {};
commonlib.setfield("CommonCtrl.Motion.MotionResource",MotionResource);

local AnimatorManager = {
   name = "AnimatorManager.instance",
   -- his parent is a AnimatorEngine
   parent = nil,
   -- all of animators is in AnimatorPool
   levelList = {},
   
   --event
   OnFail = nil,
}

commonlib.setfield("CommonCtrl.Motion.AnimatorManager",AnimatorManager);

syntax

function AnimatorManager:new(o)

parameters

o  

AnimatorManager:GetFrameLength

return the max length in whole levels

syntax

function AnimatorManager:GetFrameLength()

AnimatorManager:DoPlay

DoPlay

syntax

function AnimatorManager:DoPlay()

Member Functions

BezierSegment:getValue

[[ /** * Calculates the location of a two-dimensional cubic Bezier curve at a specific time. * * @param t The time or degree of progress along the curve, as a decimal value between 0 and 1. *

Note: The t parameter does not necessarily move along the curve at a uniform speed. For example, a t value of 0.5 does not always produce a value halfway along the curve.

* * @return A point object containing the x and y coordinates of the Bezier curve at the specified time. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Bezier curve, node, Copy Motion as ActionScript */ --]]

syntax

function BezierSegment:getValue(t)

parameters

t  

CommonCtrl.Motion.BezierSegment.getSingleValue

[[ /** * Calculates the value of a one-dimensional cubic Bezier equation at a specific time. * By contrast, a Bezier curve is usually two-dimensional * and uses two of these equations, one for the x coordinate and one for the y coordinate. * * @param t The time or degree of progress along the curve, as a decimal value between 0 and 1. *

Note: The t parameter does not necessarily move along the curve at a uniform speed. For example, a t value of 0.5 does not always produce a value halfway along the curve.

* * @param a The first value of the Bezier equation. * * @param b The second value of the Bezier equation. * * @param c The third value of the Bezier equation. * * @param d The fourth value of the Bezier equation. * * @return The value of the Bezier equation at the specified time. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Bezier curve, node, Copy Motion as ActionScript */ ]]

syntax

function CommonCtrl.Motion.BezierSegment.getSingleValue(t, a, b, c, d)

parameters

t  
a  
b  
c  
d  

CommonCtrl.Motion.BezierSegment.getCubicCoefficients

[[ /** * Calculates the coefficients for a cubic polynomial equation, * given the values of the corresponding cubic Bezier equation. * * @param a The first value of the Bezier equation. * * @param b The second value of the Bezier equation. * * @param c The third value of the Bezier equation. * * @param d The fourth value of the Bezier equation. * * @return An array containing four number values, * which are the coefficients for a cubic polynomial. * The coefficients are ordered from the highest degree to the lowest, * so the first number in the array would be multiplied by t^3, the second by t^2, and so on. * * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Bezier curve, node, Copy Motion as ActionScript * @see #getCubicRoots() */ ]]

syntax

function CommonCtrl.Motion.BezierSegment.getCubicCoefficients(a, b, c, d)

parameters

a  
b  
c  
d  

CommonCtrl.Motion.BezierSegment.getCubicRoots

[[ /** * Finds the real solutions, if they exist, to a cubic polynomial equation of the form: at^3 + bt^2 + ct + d. * This method is used to evaluate custom easing curves. * * @param a The first coefficient of the cubic equation, which is multiplied by the cubed variable (t^3). * * @param b The second coefficient of the cubic equation, which is multiplied by the squared variable (t^2). * * @param c The third coefficient of the cubic equation, which is multiplied by the linear variable (t). * * @param d The fourth coefficient of the cubic equation, which is the constant. * * @return An array of number values, indicating the real roots of the equation. * There may be no roots, or as many as three. * Imaginary or complex roots are ignored. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Bezier curve, node, Copy Motion as ActionScript */ ]]

syntax

function CommonCtrl.Motion.BezierSegment.getCubicRoots(a, b, c, d)

parameters

a  
b  
c  
d  

CommonCtrl.Motion.BezierSegment.getQuadraticRoots

[[ /** * Finds the real solutions, if they exist, to a quadratic equation of the form: at^2 + bt + c. * * @param a The first coefficient of the quadratic equation, which is multiplied by the squared variable (t^2). * * @param b The second coefficient of the quadratic equation, which is multiplied by the linear variable (t). * * @param c The third coefficient of the quadratic equation, which is the constant. * * @return An array of number values, indicating the real roots of the equation. * There may be no roots, or as many as two. * Imaginary or complex roots are ignored. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Bezier curve, node, Copy Motion as ActionScript */ ]]

syntax

function CommonCtrl.Motion.BezierSegment.getQuadraticRoots(a, b, c)

parameters

a  
b  
c  

Member Functions

Color:setTint

[[ /** * Sets the tint color and amount at the same time. * * @param tintColor The tinting color value in the 0xRRGGBB format. * * @param tintMultiplier The percentage to apply the tint color, as a decimal value between 0 and 1. * When tintMultiplier = 0, the target object is its original color and no tint color is visible. * When tintMultiplier = 1, the target object is completely tinted and none of its original color is visible. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword brightness, Copy Motion as ActionScript */ ]]

syntax

function Color:setTint(tintColor, tintMultiplier)

parameters

tintColor  
tintMultiplier  

Color:GetTintColor

[[ /** * The tinting color value in the 0xRRGGBB format. * * * @default 0x000000 (black) * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword tint, Copy Motion as ActionScript */ ]]

syntax

function Color:GetTintColor()

Color:deriveTintColor

[[ // Capable of deriving a tint color from the color offsets, // but the accuracy decreases as the tint multiplier decreases (rounding issues). /** * @private */ ]]

syntax

function Color:deriveTintColor()

Color:GetTintMultiplier

[[ /** * The percentage to apply the tint color, as a decimal value between 0 and 1. * When tintMultiplier = 0, the target object is its original color and no tint color is visible. * When tintMultiplier = 1, the target object is completely tinted and none of its original color is visible. * @default 0 * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword tint, Copy Motion as ActionScript */ ]]

syntax

function Color:GetTintMultiplier()

CommonCtrl.Motion.Color.interpolateTransform

[[ /** * Blends smoothly from one ColorTransform object to another. * * @param fromColor The starting ColorTransform object. * * @param toColor The ending ColorTransform object. * * @param progress The percent of the transition as a decimal, where 0 is the start and 1 is the end. * * @return The interpolated ColorTransform object. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword blend, Copy Motion as ActionScript */ ]]

syntax

function CommonCtrl.Motion.Color.interpolateTransform(fromColor, toColor, progress)

parameters

fromColor  
toColor  
progress  

Member Functions

CustomEase:GetTarget

[[ /** * The name of the animation property to target. * @default "" * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Animation, target, Copy Motion as ActionScript * @see fl.motion.ITween#target */ ]]

syntax

function CustomEase:GetTarget()

Member Functions

DisplayObject:Init

function DisplayObject:InitObjectProperty() --local display = self:GetDisplayObj(); --if(display)then --self.translationx = display.x; --self.translationy = display.y; --self.rotation = display.rotation; --self.defaultColor = display.color; -- --self.scaleX = display.scalingx; --self.scaleY = display.scalingy; --end -- end

syntax

function DisplayObject:Init()

Member Functions

Keyframe:GetIndex

The keyframe's unique time value in the motion tween. The first frame in a motion tween has an index of 0.

syntax

function Keyframe:GetIndex()

Keyframe:GetRotation

Indicates the rotation of the target object in degrees from its original orientation as applied from the transformation point. A value of NaN means that the keyframe does not affect self property.

syntax

function Keyframe:GetRotation()

Keyframe:getValue

Retrieves the value of a specific tweenable property on the keyframe.

  • param __ :tweenableName The name of a tweenable property, such as "x"

syntax

function Keyframe:getValue(tweenableName)

parameters

tweenableName  

Keyframe:getTween

Retrieves an ITween object for a specific animation property.

  • param __ :target The name of the property being tweened.

syntax

function Keyframe:getTween(target)

parameters

target  

Keyframe:affectsTweenable

Indicates whether the keyframe has an influence on a specific animation property.

  • param __ :tweenableName The name of a tweenable property, such as "x" or "rotation".

syntax

function Keyframe:affectsTweenable(tweenableName)

parameters

tweenableName  

Member Functions

Motion:GetDuration

Controls the Motion instance's length of time, measured in frames. The duration cannot be less than the time occupied by the Motion instance's keyframes.

syntax

function Motion:GetDuration()

Motion:getCurrentKeyframe

[[ /** * Retrieves the keyframe that is currently active at a specific frame in the Motion instance. * A frame that is not a keyframe derives its values from the keyframe that preceded it. * *

This method can also filter values by the name of a specific tweenables property. * You can find the currently active keyframe for x, which may not be * the same as the currently active keyframe in general.

* * @param index The index of a frame in the Motion instance, as an integer greater than or equal to zero. * * @param tweenableName Optional name of a tweenable's property (like "x" or "rotation"). * * @return The closest matching keyframe at or before the supplied frame index. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Motion, Copy Motion as ActionScript * @see fl.motion.Tweenables */ ]]

syntax

function Motion:getCurrentKeyframe(index, tweenableName)

parameters

index  
tweenableName  

Motion:getNextKeyframe

[[ /** * Retrieves the next keyframe after a specific frame in the Motion instance. * If a frame is not a keyframe, and is in the middle of a tween, * self method derives its values from both the preceding keyframe and the following keyframe. * *

This method can also filter by the name of a specific tweenables property. * This allows you to find the next keyframe for x, which may not be * the same as the next keyframe in general.

* * @param index The index of a frame in the Motion instance, as an integer greater than or equal to zero. * * @param tweenableName Optional name of a tweenable's property (like "x" or "rotation"). * * @return The closest matching keyframe after the supplied frame index. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword Motion, Copy Motion as ActionScript * @see fl.motion.Tweenables */ ]]

syntax

function Motion:getNextKeyframe(index, tweenableName)

parameters

index  
tweenableName  

Motion:GetTableLen

because some table set value like this way local t = {}; t[3] = 3; t[9] = 9; so the method of table.getn( t ) can't get the lenght of the table

syntax

function Motion:GetTableLen(t)

parameters

t  

Member Functions

CommonCtrl.Motion.SimpleEase.easeQuadPercent

[[ /** * Calculates an interpolated value for a numerical property of animation, * using a percentage of quadratic easing. * The function signature matches that of the easing functions in the fl.motion.easing package. * * @param time This value is between 0 and duration, inclusive. * You can choose any unit (for example, frames, seconds, milliseconds), * but your choice must match the duration unit. * * @param begin The value of the animation property at the start of the tween, when time is 0. * * @param change The change in the value of the animation property over the course of the tween. * This value can be positive or negative. For example, if an object rotates from 90 to 60 degrees, the change is -30. * * @param duration The length of time for the tween. This value must be greater than zero. * You can choose any unit (for example, frames, seconds, milliseconds), * but your choice must match the time unit. * * @param percent A percentage between -1 (100% ease in or acceleration) and 1 (100% ease out or deceleration). * * @return The interpolated value at the specified time. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword SimpleEase, Copy Motion as ActionScript * @see fl.motion.easing */ ]]

syntax

function CommonCtrl.Motion.SimpleEase.easeQuadPercent(time, begin, change, duration, percent) 

parameters

time  
begin  
change  
duration  
percent  

CommonCtrl.Motion.SimpleEase.easeNone

[[ /** * Calculates an interpolated value for a numerical property of animation, * using a linear tween of constant velocity. * The function signature matches that of the easing functions in the fl.motion.easing package. * * @param time This value is between 0 and duration, inclusive. * You can choose any unit(for example, frames, seconds, milliseconds), * but your choice must match the duration unit. * * @param begin The value of the animation property at the start of the tween, when time is 0. * * @param change The change in the value of the animation property over the course of the tween. * This value can be positive or negative. For example, if an object rotates from 90 to 60 degrees, the change is -30. * * @param duration The length of time for the tween. This value must be greater than zero. * You can choose any unit (for example, frames, seconds, milliseconds), * but your choice must match the time unit. * * @return The interpolated value at the specified time. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword SimpleEase, Copy Motion as ActionScript * @see fl.motion.easing */ ]]

syntax

function CommonCtrl.Motion.SimpleEase.easeNone(time, begin, change, duration) 

parameters

time  
begin  
change  
duration  

SimpleEase:getValue

[[ /** * Calculates an interpolated value for a numerical property of animation, * using a percentage of quadratic easing. * The percent value is read from the SimpleEase instance's ease property * rather than being passed into the method. * Using this property allows the function signature to match the ITween interface. * * @param time This value is between 0 and duration, inclusive. * You can choose any unit (for example, frames, seconds, milliseconds), * but your choice must match the duration unit. * * @param begin The value of the animation property at the start of the tween, when time is 0. * * @param change The change in the value of the animation property over the course of the tween. * This value can be positive or negative. For example, if an object rotates from 90 to 60 degrees, the change is -30. * * @param duration The length of time for the tween. This value must be greater than zero. * You can choose any unit (for example, frames, seconds, milliseconds), * but your choice must match the time unit. * * @return The interpolated value at the specified time. * @playerversion Flash 9.0.28.0 * @langversion 3.0 * @keyword SimpleEase, Copy Motion as ActionScript * @see #ease */ ]]

syntax

function SimpleEase:getValue(time, begin, change, duration)

parameters

time  
begin  
change  
duration  

Member Functions

CommonCtrl.Motion.motion_test.onStart


syntax

function CommonCtrl.Motion.motion_test.onStart()

CommonCtrl.Motion.motion_test.OnDlgResult

called when dialog returns.

syntax

function CommonCtrl.Motion.motion_test.OnDlgResult(dialogResult)

parameters

dialogResult  
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback