[摘要]实现可以拖动热点的代码,原理是不断读取鼠标坐标,并转换为球面坐标。
实现代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<!-- 加入以下控制拖动的动作draghotspot --> <action name="draghotspot"> if(%1 != dragging, spheretoscreen(ath, atv, hotspotcenterx, hotspotcentery); sub(drag_adjustx, mouse.stagex, hotspotcenterx); sub(drag_adjusty, mouse.stagey, hotspotcentery); draghotspot(dragging); , if(pressed, sub(dx, mouse.stagex, drag_adjustx); sub(dy, mouse.stagey, drag_adjusty); screentosphere(dx, dy, ath, atv); copy(print_ath, ath); copy(print_atv, atv); roundval(print_ath, 3); roundval(print_atv, 3); ); ); </action> <!-- 在需要拖动的热点中ondown动作执行draghotspot动作即可 --> <hotspot name="spot1" url="hotspot.png" zoom="true" scale="0.5" ath="-35" atv="+6" ondown="draghotspot();" /> <hotspot name="spot2" url="hotspot.png" zoom="true" scale="0.5" ath="-1" atv="+24" ondown="draghotspot();" /> <hotspot name="spot3" url="hotspot.png" distorted="true" scale="0.5" ath="+20" atv="+8" ondown="draghotspot();" /> <hotspot name="spot4" url="hotspot.png" distorted="true" scale="0.5" ath="+32" atv="+16" ondown="draghotspot();" /> |