Advertisement
pedroadmn

Exemplo de Uso - Linear Acceleration

Apr 12th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MXML 2.23 KB | None | 0 0
  1. <!-- Coke Theme Example -->
  2.  
  3. <VariableBinders>
  4.     <SensorBinder type="linear_acceleration">
  5.         <Variable name="linear_acceleration_x" index="0" />
  6.         <Variable name="linear_acceleration_y" index="1" />
  7.         <Variable name="linear_acceleration_z" index="2" />
  8.     </SensorBinder>
  9. </VariableBinders>
  10.  
  11. <!-- 三个方向的甩动计数 -->
  12. <Var name="line_x" expression="#linear_acceleration_x" threshold="1">
  13.     <Trigger>
  14.         <VariableCommand name="plus_x" expression="ifelse((le(#line_x,-3)+ge(#line_x,3))*le(#pre_line_x*#line_x,0),1,0)" />
  15.         <VariableCommand name="shake_time" expression="#shake_time+1" condition="#plus_x" />
  16.         <VariableCommand name="pre_line_x" expression="ifelse(#plus_x,#line_x,#pre_line_x)" />
  17.     </Trigger>
  18. </Var>
  19.  
  20. <Var name="line_y" expression="#linear_acceleration_y" threshold="1">
  21.     <Trigger>
  22.         <VariableCommand name="plus_y" expression="ifelse((le(#line_y,-3)+ge(#line_y,3))*le(#pre_line_y*#line_y,0),1,0)" />
  23.         <VariableCommand name="shake_time" expression="#shake_time+1" condition="#plus_y" />
  24.         <VariableCommand name="pre_line_y" expression="ifelse(#plus_y,#line_y,#pre_line_y)" />
  25.     </Trigger>
  26. </Var>
  27.  
  28. <Var name="line_z" expression="#linear_acceleration_z" threshold="1">
  29.     <Trigger>
  30.         <VariableCommand name="plus_z" expression="ifelse((le(#line_z,-3)+ge(#line_z,3))*le(#pre_line_z*#line_z,0),1,0)" />
  31.         <VariableCommand name="shake_time" expression="#shake_time+1" condition="#plus_z" />
  32.         <VariableCommand name="pre_line_z" expression="ifelse(#plus_z,#line_z,#pre_line_z)" />
  33.     </Trigger>
  34. </Var>
  35.  
  36.     <!-- 摇晃动画 -->
  37. <Var name="line" expression="#linear_acceleration_x+10*#linear_acceleration_y+100*#linear_acceleration_z" threshold="1">
  38.     <Trigger>
  39.         <VariableCommand name="rock_angle" expression="-10" condition="ge(#shake_time,2)" />
  40.         <Comman target="coke_n.animation" value="play" condition="ge(#shake_time,2)" />
  41.         <VariableCommand name="rock_angle" expression="0" delay="1500" delayCondition="le((abs(#line_x)+abs(#line_y)+abs(#line_z)),2)" />
  42.         <VariableCommand name="shake_time" expression="0" delay="100" condition="ge(#shake_time,2)" />
  43.         <!-- <SoundCommand sound="silence.mp3" volume="1" keepCur="false"  delay="1500"         delayCondition="le((abs(#line_x)+abs(#line_y)+abs(#line_z)),2)" /> -->
  44.     </Trigger>
  45. </Var>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement