Hi, so i have tried to make an image being moved using buttons, but it didn't work .
Here's how the code did look like:
But it just didn't move.
Could anyone help me with that?
Here's how the code did look like:
B4X:
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim ImageView1 As ImageView
Dim Down As Button
Dim Left As Button
Dim Right As Button
Dim Up As Button
Dim x1 As Int
Dim x2 As Int
Dim y1 As Int
Dim y1 As Int
x1 = 25%x
x2 = 50%x
y1 = 25%y
y2 = 50%y
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main.bal") 'load the designer layout (just the gradient color in this case).
ImageView1.Initialize("")
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "smiley.gif")
Activity.AddView(ImageView1, x1, y1, x2, y2)
End Sub
Sub Activity_Pause
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Touch(Action As Int, tx As Float, ty As Float)
End Sub
Sub Up_Click
'Activity.AddView(left,top,width,height)
y1 = y1 - 5
End Sub
Sub Right_Click
x1 = x1 + 5
End Sub
Sub Left_Click
x1 = x1 - 5
End Sub
Sub Down_Click
y1 = y1 + 5
End Sub
Sub Timer1_Tick
Activity.RemoveViewAt(0)
Activity.AddView(ImageView1, x1, y1, x2, y2)
End Sub
But it just didn't move.
Could anyone help me with that?