let say you have an imageview and you would like to show an animation in it. so let say your animation has 5 images. you could do something like this
create an array of all bitmaps
then intialize the bitmaps (note that we name the images like this: pic0.png, pic1.png, pic2.png,...)
now come the tricky part
because we would like to show an animation that always continue we can say something like this:
it will work but we could make our code shorter if we use MODULUS
create an array of all bitmaps
B4X:
Sub Process_Globals
'...
Dim img As ImageView
Dim bmp(5) As Image
End Sub
then intialize the bitmaps (note that we name the images like this: pic0.png, pic1.png, pic2.png,...)
B4X:
'...
For i = 0 To bmp.Length-1
bmp(i).Initialize(File.DirApp,"pic" & i & ".png")
Next
'...
now come the tricky part
because we would like to show an animation that always continue we can say something like this:
B4X:
Sub timer_tick
index = index + 1
If index > bmp.Length-1 Then
index = 0
End If
img.SetImage(bmp(index))
End Sub
it will work but we could make our code shorter if we use MODULUS
B4X:
Sub timer_tick
index = (index + 1) Mod 5
img.SetImage(bmp(index))
End Sub