After <VariableBinders> is declared, the system global variable shake is generated. Each time a user shakes the mobile phone at an amplitude reaching the threshold, the value of shake is incremented by 1. The interval between two changes of the value cannot be less than 1000 milliseconds.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
shake | Number | Yes | Shaking times. It is a global variable. You can reference the parameter value through #shake. Each time a user shakes the mobile phone at an amplitude reaching the threshold, the value of shake is incremented by 1. The interval between two changes of the value cannot be smaller than 1000 milliseconds. |
Example 1: Rotate three images through shaking. Each time a user shakes the mobile phone at an amplitude reaching the threshold, the value of shake is incremented by 1. The interval between two changes of the value cannot be less than 1000 milliseconds. The value of srcid is 0, 1, or 2.
<Image x="529.5" y="1410" src="djs.png" srcid="#shake%3" align="center" alignV="center"></Image>
Example 2: Shake the mobile phone to trigger vibration and use the #shake variable to control animation visibility.
<VariableBinders>
<SensorBinder type="accelerometer" vibrate="1" shakeTime="400" delay="0">
<Variable name="x_acc" index="0"/>
</SensorBinder>
</VariableBinders>
<Image name="animation" x="540" y="0" w="1080" h="2400" align="center" visibility="0">
<SourcesAnimation repeat="1">
<Source src="dawa_alpha.png" time="0"/>
<Source src="dawa_alpha.png" time="10"/>
<Source src="dawa_1.png" time="80"/>
<Source src="dawa_2.png" time="160"/>
<Source src="dawa_3.png" time="240"/>
<Source src="dawa_4.png" time="320"/>
<Source src="dawa_5.png" time="400"/>
<Source src="dawa_6.png" time="480"/>
<Source src="dawa_7.png" time="560"/>
<Source src="dawa_8.png" time="640"/>
<Source src="dawa_9.png" time="720"/>
<Source src="dawa_10.png" time="800"/>
<Source src="dawa_11.png" time="880"/>
<Source src="dawa_12.png" time="960"/>
<Source src="dawa_13.png" time="1040"/>
<Source src="dawa_14.png" time="1120"/>
<Source src="dawa_15.png" time="1200"/>
<Source src="dawa_16.png" time="1280"/>
<Source src="dawa_17.png" time="1360"/>
<Source src="dawa_18.png" time="1440"/>
<Source src="dawa_19.png" time="1520"/>
<Source src="dawa_20.png" time="1600"/>
<Source src="dawa_21.png" time="1680"/>
<Source src="dawa_22.png" time="1760"/>
<Source src="dawa_23.png" time="1840"/>
<Source src="dawa_24.png" time="1920"/>
<Source src="dawa_alpha.png" time="1923"/>
</SourcesAnimation>
</Image>
<Var name="shake_record" expression="#shake" threshold="1">
<Trigger>
<Command target="animation.visibility" value="true"/>
<Command target="animation.visibility" value="false" delay="1920"/>
</Trigger>
</Var>