Advertisement
pedroadmn

SampleLockScreenSensor

May 5th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MXML 2.91 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Lockscreen version="1" frameRate="60" screenWidth="720">
  3.     <!--Constructing the orientation sensor.-->
  4.     <VariableBinders>
  5.         <SensorBinder type="orientation">
  6.             <!--Specifyingthe type-->
  7.             <Variable name="_orientation_x" index="0" />
  8.             <Variable name="_orientation_y" index="1" />
  9.             <!--Declaring the 3 variable to assign the gravity value in each axis.-->
  10.             <Variable name="_orientation_z" index="2" />
  11.         </SensorBinder>
  12.     </VariableBinders>
  13.     <!--Ploting a background image in the lockscreen at the position (0,0) and height(h)=#screen_height
  14.     and width(w)="#screen_width"-->
  15.     <Image src="images/bg_blue.png" x="0" y="0" h="#screen_height" w="#screen_width" />
  16.     <!--Constructing an image group that will build a compass.-->
  17.     <Group>
  18.         <Image x="#screen_width/2" y="#screen_height/2" align="center" alignV="center" w="400" h="400" src="images/bg.png" />
  19.         <!--The sensor will be used in this image to rotate it. pivotX and pivotY specify the rotation point, in this case, in the image center.
  20.             The rotation will be according to orientation in the axis x that we can obtain with the sensor variable _orientation_x-->
  21.         <Image x="#screen_width/2" y="#screen_height/2" align="center" alignV="center" w="400" h="400" pivotX="200" pivotY="200" rotation="-#_orientation_x" src="images/arrow.png" />
  22.         <Image x="#screen_width/2" y="#screen_height/2" align="center" alignV="center" w="400" h="400" pivotX="200" src="images/thumb.png" />
  23.     </Group>
  24.     <!--If you want to see the sensor variable values on screen uncomment the lines below-->
  25.     <!--<Text x="10" y="10" size="20" format="Orientation x: %d" paras="#_orientation_x" color="#000000" />
  26.     <Text x="10" y="40" size="20" format="Orientation y: %d" paras="#_orientation_y" color="#000000" />
  27.     <Text x="10" y="70" size="20" format="Orientation z: %d" paras="#_orientation_z" color="#000000" />-->
  28.     <!--This part of the code unlock the screen when the orientation is pointing to north(in this case we are
  29.     using the interval 359-360 and 1-3). When the _orientation_x is one of this values the screen is unlock.-->
  30.     <Var name="_unlock" expression="gt(#_orientation_x,358)*le(#_orientation_x,360) + ge(#_orientation_x,1)*le(#_orientation_x,3)">
  31.         <Trigger>
  32.             <!--Delay(The time to unlock the lockscreen)-->
  33.             <ExternCommand command="unlock" delay="500" />
  34.         </Trigger>
  35.     </Var>
  36.     <!--Here we create an unlock to when the user double click on screen-->
  37.     <!--We create a buttom that has the screen size. haptic(To vibrate)-->
  38.     <Button name="_screen_button" x="0" y="0" w="#screen_width" h="#screen_height" haptic="true">
  39.         <Triggers>
  40.             <Trigger action="double">
  41.                 <!--Delay(The time to unlock the lockscreen)-->
  42.                 <ExternCommand command="unlock" delay="500" />
  43.             </Trigger>
  44.             <Trigger action="up">
  45.                 <!-- do something -->
  46.             </Trigger>
  47.             <Trigger action="down">
  48.                 <!-- do something -->
  49.             </Trigger>
  50.         </Triggers>
  51.     </Button>
  52. </Lockscreen>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement