:sign0104:
Can I change, on the fly, the value of the TO X and/or TO Y value in the Animation library InitializeTranslate command? What I have so far does not work. Any suggestions or better way to do this would be greatly appreciated. Very new to B4A. The goal is to move a graphic of a bubble around a graphic of a bubble level based on values transmitted over bluetooth from a circuit I have built. An stuck on the graphics. This code is based on the Animate tutorial.
Thanks
Can I change, on the fly, the value of the TO X and/or TO Y value in the Animation library InitializeTranslate command? What I have so far does not work. Any suggestions or better way to do this would be greatly appreciated. Very new to B4A. The goal is to move a graphic of a bubble around a graphic of a bubble level based on values transmitted over bluetooth from a circuit I have built. An stuck on the graphics. This code is based on the Animate tutorial.
Thanks
B4X:
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim Button1 As Button
Dim Button6 As Button
Dim a6 As Animation
Dim f_x As Float
Dim f_y As Float
Dim t_x As Float
Dim t_y As Float
Dim txt1 As EditText
Dim txt2 As EditText
Dim y As Float
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
f_x = 0 ' From X
f_y = 0 ' From Y
t_x = 0 ' Too X
t_y = 10 ' Too Y
y = 0 ' Vriable for new y value
Dim animations() As Animation
a6.InitializeTranslate("Animation", f_x, f_y, t_x, t_y)
Button6.Tag = a6
Button1.Tag = "b1"
animations = Array As Animation(a6)
For i = 0 To animations.Length - 1
animations(i).Duration = 1000
Next
End Sub
Sub Animation_AnimationEnd
If Sender = a6 Then
txt1.Text = "fx="&f_x & " fy="&f_y & " tx="&t_x & " ty="&t_y & " b6="&Button6.Top
' Message to verify if Y changed or not
f_x = t_x
f_y = t_y
t_x = t_x
Button6.Top = Button6.Top + y
txt2.Text = "fx="&f_x & " fy="&f_y & " tx="&t_x & " ty="&t_y & " b6="&Button6.top
End If
End Sub
Sub Button_Click
If Button1.Tag = a6 Then
y = 50
Else
y = 10
End If
t_y = y
'a6.InitializeTranslate("Animation", f_x, f_y, t_x, t_y) ' Stopped the PNG moving smoothly
a6.Start(Button6)
End Sub