注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

沉默蜂B4A安卓编程

国内资料最全的B4A资料库

 
 
 

日志

 
 

拖动图片(GestureDetector_Drag)  

2015-09-30 11:37:47|  分类: B.图形 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

拖动图片(GestureDetector_Drag) - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
运行效果图

#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Gesture detector demo
#VersionCode: 1
#VersionName: 
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub

Sub Globals
Dim GD As GestureDetector
Dim pnlGreen As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim lbl As Label
lbl.Initialize("")
lbl.Text = "Move the green ball with the finger."
lbl.TextColor = Colors.White
lbl.TextSize = 18
Activity.AddView(lbl, 15dip, 15dip, 100%x-30dip, 60dip)
pnlGreen.Initialize("")
pnlGreen.SetBackgroundImage(LoadBitmap(File.DirAssets, "greenball.png"))
Activity.AddView(pnlGreen, 30dip, 70dip, 100dip, 100dip)
GD.SetOnGestureListener(pnlGreen, "Gesture")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub Gesture_onTouch(Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
Log("onTouch action=" & Action & ", x=" & X & ", y=" & Y & ", ev=" & MotionEvent)
Return True
End Sub
Sub Gesture_onDown(X As Float, Y As Float, MotionEvent As Object)
Log("   onDown x = " & X & ", y = " & Y & ", ev = " & MotionEvent)
Log("      pressure = " & GD.getPressure(MotionEvent, 0))
Log("      size = " & GD.getSize(MotionEvent, 0))
End Sub
Sub Gesture_onDrag(deltaX As Float, deltaY As Float, MotionEvent As Object)
Log("   onDrag deltaX = " & deltaX & ", deltaY = " & deltaY & ", ev = " & MotionEvent)
pnlGreen.Left = Max(0, Min(pnlGreen.Left + deltaX, 100%x - pnlGreen.Width))
pnlGreen.Top = Max(0, Min(pnlGreen.Top + deltaY, 100%y - pnlGreen.Height))
End Sub
Sub Gesture_onFling(velocityX As Float, velocityY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
Log("   onFling velocityX = " & velocityX & ", velocityY = " & velocityY & ", ev1 = " & MotionEvent1 & ", ev2 = " & MotionEvent2)
End Sub

 
  评论这张
 
阅读(76)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017