got labels moving
I managed to drag my labels around the screen, now im having trouble getting them to lock into place. Here is the code im using to get the labels to drag around the screen.
Level 1 activity:
Sub Globals
Dim btnenter As Button
Dim btnnext As Button
Dim btnexit As Button
Dim imgpic As ImageView
Dim lblletter As Label
Dim lblletter2 As Label
Dim lblletter3 As Label
Dim lblrandom As Label
Dim lblrandom2 As Label
Dim lblrandom3 As Label
Dim lblrandom4 As Label
Dim lblrandom5 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("level1")
Dim dv1, dv2, dv3, dv4, dv5 As dragging
dv1.Initialize(Activity, lblrandom)
dv2.Initialize(Activity, lblrandom2)
dv3.Initialize(Activity, lblrandom3)
dv4.Initialize(Activity, lblrandom4)
dv5.Initialize(Activity, lblrandom5)
End Sub
Dragging class:
Sub Class_Globals
Private innerview As View
Private lblletter As Label
Private lblletter2 As Label
Private lblletter3 As Label
Private lblrandom As Label
Private lblrandom2 As Label
Private lblrandom3 As Label
Private lblrandom4 As Label
Private lblrandom5 As Label
Private downx, downy As Int
Private ACTION_DOWN, ACTION_MOVE, ACTION_UP As Int
End Sub
Public Sub Initialize(Activity As Activity, v As View)
innerview = v
lblrandom.Initialize("")
'pnl1.Color = Colors.Transparent
Activity.AddView(lblrandom, v.Left, v.Top, v.Width, v.Height)
ACTION_DOWN = Activity.ACTION_DOWN
ACTION_MOVE = Activity.ACTION_MOVE
ACTION_UP = Activity.ACTION_UP
Dim r As Reflector
r.Target = lblrandom
r.SetOnTouchListener("lblrandom_Touch")
innerview = v
lblrandom2.Initialize("")
Activity.AddView(lblrandom2, v.Left, v.Top, v.Width, v.Height)
ACTION_DOWN = Activity.ACTION_DOWN
ACTION_MOVE = Activity.ACTION_MOVE
ACTION_UP = Activity.ACTION_UP
Dim r As Reflector
r.Target = lblrandom2
r.SetOnTouchListener("lblrandom2_Touch")
innerview = v
lblrandom3.Initialize("")
Activity.AddView(lblrandom3, v.Left, v.Top, v.Width, v.Height)
ACTION_DOWN = Activity.ACTION_DOWN
ACTION_MOVE = Activity.ACTION_MOVE
ACTION_UP = Activity.ACTION_UP
Dim r As Reflector
r.Target = lblrandom3
r.SetOnTouchListener("lblrandom3_Touch")
innerview = v
lblrandom4.Initialize("")
Activity.AddView(lblrandom4, v.Left, v.Top, v.Width, v.Height)
ACTION_DOWN = Activity.ACTION_DOWN
ACTION_MOVE = Activity.ACTION_MOVE
ACTION_UP = Activity.ACTION_UP
Dim r As Reflector
r.Target = lblrandom4
r.SetOnTouchListener("lblrandom4_Touch")
innerview = v
lblrandom5.Initialize("")
Activity.AddView(lblrandom5, v.Left, v.Top, v.Width, v.Height)
ACTION_DOWN = Activity.ACTION_DOWN
ACTION_MOVE = Activity.ACTION_MOVE
ACTION_UP = Activity.ACTION_UP
Dim r As Reflector
r.Target = lblrandom5
r.SetOnTouchListener("lblrandom5_Touch")
End Sub
Private Sub lblrandom_Touch (o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = ACTION_DOWN Then
downx = x
downy = y
Else
Log("not down")
innerview.Left = innerview.Left + x - downx
innerview.Top = innerview.Top + y - downy
lblrandom.Left = innerview.Left
lblrandom.Top = innerview.Top
End If
Return True
End Sub
Private Sub lblrandom2_Touch (o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = ACTION_DOWN Then
downx = x
downy = y
Log("2 down")
Else
innerview.Left = innerview.Left + x - downx
innerview.Top = innerview.Top + y - downy
lblrandom2.Left = innerview.Left
lblrandom2.Top = innerview.Top
End If
Return True
End Sub
Private Sub lblrandom3_Touch (o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = ACTION_DOWN Then
downx = x
downy = y
Log("3 down")
Else
innerview.Left = innerview.Left + x - downx
innerview.Top = innerview.Top + y - downy
lblrandom3.Left = innerview.Left
lblrandom3.Top = innerview.Top
End If
Return True
End Sub
Private Sub lblrandom4_Touch (o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = ACTION_DOWN Then
downx = x
downy = y
Log("4 down")
Else
innerview.Left = innerview.Left + x - downx
innerview.Top = innerview.Top + y - downy
lblrandom4.Left = innerview.Left
lblrandom4.Top = innerview.Top
End If
Return True
End Sub
Private Sub lblrandom5_Touch (o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = ACTION_DOWN Then
downx = x
downy = y
Log(motion)
Log("5 down")
lblrandom5.Top = 10
lblrandom5.Left = 5
lblrandom5.Text = "5"
'
' Else
' innerview.Left = innerview.Left + x - downx
' innerview.Top = innerview.Top + y - downy
' lblrandom5.Left = innerview.Left
' lblrandom5.Top = innerview.Top
'
End If
Return True
End Sub
I have tried lblrandom.Top = 460 ect and lblrandom.Left = 230 ect but with no luck, no matter where i place it it doesnt effect the labels. Where am i going wrong? Any ideas?:sign0163: