合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
Unlocker是一个滑动解锁的命令,与滑动组件Slider用法类似,当起始点(StartPoint)的x,y点随手指移动落入EndPoint目标矩形区域时,松开手指则触发解锁。
- <Unlocker name="" bounceInitSpeed="" bounceAcceleration="">
- <StartPoint x="" y="" w="" h="" normalSound="" pressedSound=""/>
- <EndPoint x="" y="" w="" h="" reachedSound=""/>
- </Unlocker>
参 数 | 类 型 | 选 项 | 注 释 |
|---|---|---|---|
name | 字符串 | 必填 | 解锁控件的变量名,通过[name].move_y可以得到解锁部件在y轴的偏移量 |
bounceInitSpeed | 数值 | 选填 | 回弹动画的初始速度(距离单位为像素,时间单位为秒),都支持表达式,最小100,默认值为0 |
bounceAcceleration | 数值 | 选填 | 回弹动画的加速度(距离单位为像素,时间单位为秒),都支持表达式,最小10,默认值为0 |
参 数 | 类 型 | 选 项 | 注 释 |
|---|---|---|---|
x | 数值 | 必填 | 起始点相对于屏幕左上角的x坐标 |
y | 数值 | 必填 | 起始点相对于屏幕左上角的y坐标 |
w | 数值 | 选填 | 起始点响应区域的大小,宽 |
h | 数值 | 选填 | 起始点响应区域的大小,高 |
normalSound | 字符串 | 选填 | 普通状态下播放的音效 |
pressedSound | 字符串 | 选填 | 解锁控件在press状态播放的音效 |
reachedSound | 字符串 | 选填 | 到达EndPoint所在区域时播放的音效 |
Path | 字符串 | 选填 | 定义了Slider滑动允许的范围,滑动的范围位于Position的连线上面,Path中给予了Position一个基础值,可以简单的认为是从Path定义的x加上Position的x,Path的y加上Position的y的两个Position之间的连线 |
示例一:y轴滑动解锁,当用户触发解锁操作并处于起始区域时,播放sound_pressed.mp3音乐,当到达目标区域时,播放sound_reached.mp3音乐。
- <Unlocker name="unlocker">
- <StartPoint x="0" y="440" w="480" h="400" normalSound="sound_normal.mp3" pressedSound="sound_normal.mp3"/>
- <EndPoint x="0" y="640" w="480" h="400" reachedSound="sound_reached.mp3"/>
- </Unlocker>
示例二: 滑动到目标区域解锁,如果未达到目标区域则回弹到起始区域。
- <Unlocker name="unlocker1" bounceInitSpeed="2000" bounceAcceleration="3000" >
- <StartPoint x="540" y="320" w="400" h="300"/>
- <EndPoint x="540" y="320-500" w="400" h="300">
- <Path x="540" y="320" w="400" h="300">
- <Position x="0" y="0"/>
- <Position x="0" y="-300"/>
- </Path>
- </EndPoint>
- </Unlocker>
示例三:演示任意上滑解锁,当上滑距离在100-150像素之间解锁。
- <!-- 任意上滑解锁 -->
- <Unlocker name="unlocker" bounceInitSpeed="2000" bounceAcceleration="3000" >
- <StartPoint x="0" y="0" w="#screen_width" h="#screen_height">
- </StartPoint>
- <EndPoint x="0" y="-300" w="#screen_width" h="200">
- <Path x="0" y="0" w="#screen_width" h="#screen_height">
- <Position x="0" y="0"/>
- <Position x="0" y="-150"/>
- </Path>
- </EndPoint>
- </Unlocker>