文章目录
更新于 2020.11.19 krpano 1.20.9
演示
说明
官方范例在下载包的下述位置
你电脑的路径\krpano-1.20.9\viewer\examples\control-mode\example.xml
(1.18.6)\examples\xml-usage\cursors\cursors.xml
提示:如果不明白下载包路径是什么,请查看 循序渐进(3)- krpano下载包的使用说明
krpano默认的控制方式是一种名为moveto的方式,但也有人不喜欢这种方式,希望初始时使用drag的方式,也有人希望在导航增加按钮可在两种方式间进行切换。当然,还有人想更改系统的鼠标样式,希望使用自己的样式。krpano的官方案例有这样的链接。
在1.20.9中,新的 control.mode属性整合和取代了control.mouse 和 control.touch 设置。如果使用不同的控制模式,则应该通过设备检查来实现。旧的属性仍然可用。
krpano 1.19 pr5之后的改变控制方式(krpano control)
将以下代码放到主xml中,使得控制方式在鼠标和触屏上在项目启动时就是drag的方式。
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 2 3 4 |
<action name="control_startup" autorun="onstart"> set(control.mouse, drag); set(control.touch, drag); </action> |
将以下代码放到主xml中,使得控制方式在鼠标和触屏上在项目启动时就是moveto的方式。
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 2 3 4 |
<action name="control_startup" autorun="onstart"> set(control.mouse, moveto); set(control.touch, moveto); </action> |
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 2 3 4 |
<action name="control_startup" autorun="onstart"> set(control.mouse, drag); set(control.touch, moveto); </action> |
通过按钮进行切换的方式如下,主要是onclick的部分:
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 |
onclick="switch(control.mouse,moveto,drag);switch(control.touch,moveto,drag);" |
1.18的改变控制方式(krpano control)
如果你使用的是默认的模版,你可以在krpano元素的onstart中进行条件。
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 |
<krpano version="1.17.4" title="Virtual Tour" onstart="startup();set(control.mousetype, drag2D);"> |
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 2 3 4 5 |
<action name="startup"> if(startscene === null, copy(startscene,scene[0].name)); loadscene(get(startscene), null, MERGE); set(control.mousetype, drag2D); </action> |
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 |
onclick="switch(control.mousetype,moveto,drag2d);" |
改变鼠标样式(Flash下可用)
改变鼠标样式,主要是要有一组鼠标图片。然后我们执行一个action来替换这些鼠标图片。也就是在
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 2 3 4 5 |
<plugin name="b1" style="buttonstyle" html="[p]move[/p]" align="bottom" x="-240" y="25" onclick="qtvrcursor();" /> |
点击代码窗口最右侧按钮,在新窗口打开后复制代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<action name="qtvrcursor"> set(control.mousetype, moveto); set(cursors.url, %CURRENTXML%/qtvr-cursors.png); set(cursors.type, 8way); set(cursors.move, 0|0|16|16); set(cursors.drag, 16|0|16|16); set(cursors.arrow_u, 32|0|16|16); set(cursors.arrow_d, 48|0|16|16); set(cursors.arrow_l, 64|0|16|16); set(cursors.arrow_r, 80|0|16|16); set(cursors.arrow_lu, 96|0|16|16); set(cursors.arrow_ru, 112|0|16|16); set(cursors.arrow_rd, 128|0|16|16); set(cursors.arrow_ld, 144|0|16|16); </action> |
1 |
set(control.mouse, moveto); |
- cursors.url 控制鼠标样式的图片路径
- cursors.type 类型,这里是八向类型
下面有点类似crop的用法,分别定义了在移动和拖拽,以及八个箭头方向对应的鼠标样式。查看crop的使用说明
在 “移花接木(6)- 改变krpano的控制方式与鼠标样式” 上有 1 条评论