This is a basic command. You can create an animation by configuring a variable that changes with time.
<Var name="">
<VariableAnimation delay="" repeat="">
<AniFrame value="" time=""/>
<AniFrame value="" time=""/>
</VariableAnimation>
</Var> Parameter | Type | Mandatory | Description |
|---|---|---|---|
delay | Number | No | Delay for executing a command, in milliseconds. The animation is played after the specified delay. |
repeat | Number | No | Number of times that an animation is played. If the value is 0, the animation is played for infinite times. |
value | Number | Yes | Variable value at a specific time point. |
time | Number | Yes | Number of milliseconds from the start frame, which cannot be less than 0. |
<Var name="hello" type="string">
<VariableAnimation>
<AniFrame value="Good Morning~" time="1000"/>
<AniFrame value="Good Evening~" time="2000"/>
<AniFrame value="Good Night~" time="4000"/>
<AniFrame value="Good Night~" time="40000"/>
</VariableAnimation>
</Var>
<Text textExp="@hello" size="60"/> Example 2: Bind the variable bany_2 to an image and a button, so that the image and button can be used to create an animation for interaction as the variable changes.
<Image name="yu2" x="1173.5-#bany_2" y="1171.5-#bany_2*0.5" src="yu2.png" visibility="eq(#yu2,0)"> </Image>
<Button x="1173.5-#bany_2" y="1171.5-#bany_2*0.5" w="200" h="200" visibility="eq(#yu2,0)">
<Trigger action="down">
<VariableCommand name="yu2" expression="1" persist="true"/>
<VariableCommand name="jf" expression="#jf+1" condition="le(#jf,5)" persist="true"/>
</Trigger>
</Button> Example 3: Change the value of the variable bany_2 from –200 at the beginning to 2000 at the 8000th millisecond to create an animation.
<Var name="bany_2">
<VariableAnimation>
<AniFrame value="-200" time="0"/>
<AniFrame value="2000" time="8000"/>
</VariableAnimation>
</Var>