This post will include 4 animation functions: animatefloat(),moveto(),rotateto() and scaleto().
animatefloat()this function is the most basic animation function, you can use it to change one property of a component with.
Code:
image1.animatefloat(property name,new value,duration,occasion,dynamic effect,delay,hide)
example:
Code:
image1.animatefloat("left",0,0.5,0.3,0,0,0,false);
text1.animatefloat("rotateangle",180,1)
property name: the property you want to change, such as "width","height","left","top","rotateangle"
new value: new value of the porperty, data type:int
duration: the duration of animation, unite:second
occasion: the occasion to use dynamic effect, data type:int,0~2.
- 0: use dynamic effect when animation starts.
- 1: use dynamic effect when animation ends.
- 2: use dynamic effect when animation starts and ends.
dynamic effect: data type:int,0~10. More details please refer to the XDesigner.
delay: the time to delay code execution, [data type:float]. [unite:second].
- image1.animatefloat("left",0,0.5,0.3,0,0,0.5);
- equals to
- sleep(500); // sleep(n); n:[data type:int],[unit:millisecond]
- image1.animatefloat("left",0,0.5,0.3,0,0);
hide: hide component after animation. data type:boolean, true or false.
moveto()this function is used to change component position.
Code:
image1.moveto(left,top,duration,occasion,dynamic effect,delay,hide)
example:
Code:
image1.moveto(100,30,0.5,0.3,0,0,0,false); //equals to image1.animatefloat("left",100,0.5,0.3,0,0,0,false);
// image1.animatefloat("top",30,0.5,0.3,0,0,0,false);
text1.moveto(text1.left,80,1); //equals to text1.animatefloat("top",80,1);
left: the left position
top: the top position
duration: the duration of animation, unite:second
occasion: the occasion to use dynamic effect, data type:int,0~2.
- 0: use dynamic effect when animation starts.
- 1: use dynamic effect when animation ends.
- 2: use dynamic effect when animation starts and ends.
dynamic effect: data type:int,0~10. More details please refer to the XDesigner.
delay: the time to delay code execution, [data type:float]. [unite:second].
- image1.moveto(10,10,0.5,0.3,0,0,0.5);
- equals to
- sleep(500); // sleep(n); n:[data type:int],[unit:millisecond]
- image1.movto(10,10,0.5,0.3,0,0);
hide: hide component after animation. data type:boolean, true or false.
rotateto()this function is used to change component rotateangle.
Code:
image1.rotateto(new rotateAngle,duration,occasion,dynamic effect,delay,hide)
example:
Code:
image1.rotateto(30,0.5,0.3,0,0,0,false); //equals to image1.animatefloat("rotateangle",30,0.5,0.3,0,0,0,false);
text1.rotateto(80,1); //equals to text1.animatefloat("rotateangle",80,1);
new rotateAngele: unite:degree range:minus infinity to positive infinity
duration: the duration of animation, unite:second
occasion: the occasion to use dynamic effect, data type:int,0~2.
- 0: use dynamic effect when animation starts.
- 1: use dynamic effect when animation ends.
- 2: use dynamic effect when animation starts and ends.
dynamic effect: data type:int,0~10. More details please refer to the XDesigner.
delay: the time to delay code execution, [data type:float]. [unite:second].
- image1.rotateto(10,0.5,0.3,0,0,0.5);
- equals to
- sleep(500); // sleep(n); n:[data type:int],[unit:millisecond]
- image1.rotateto(10,0.5,0.3,0,0);
hide: hide component after animation. data type:boolean, true or false.
scaleto()this function is used to scale component. you can not use animatefloat() to reach the same effect.
Code:
image1.scaleto(x scale ratio,y scale ratio,direction,duration,occasion,dynamic effect,delay,hide)
example:
Code:
image1.scaleto(0.51,0.51,"bottom",0.3,0,0,0,false);
text1.scaleto(3.5,text1.scale.y,"top",1);
x scale ratio: data type:float,0.00~6.00 1.00 means the real size.
y scale ratio: data type:float,0.00~6.00 1.00 means the real size.
direction: such as "bottom","top","center","left" and "right"
duration: the duration of animation, unite:second
occasion: the occasion to use dynamic effect, data type:int,0~2.
- 0: use dynamic effect when animation starts.
- 1: use dynamic effect when animation ends.
- 2: use dynamic effect when animation starts and ends.
dynamic effect: data type:int,0~10. More details please refer to the XDesigner.
delay: the time to delay code execution, [data type:float]. [unite:second].
- image1.scaleto(0.50,1,'center',0.3,0,0,0.5);
- equals to
- sleep(500); // sleep(n); n:[data type:int],[unit:millisecond]
- image1.scaleto(0.50,1,'center',0.3,0,0);
hide: hide component after animation. data type:boolean, true or false.