How to PRELOAD images for animations?

MarkBasik4Android

Member
Licensed User
Longtime User
Hi,
in my last test I did an animation using some PNG in sequence
I used a timer to pause between images...

Images Animation Sequence at Startup

Someone suggested me to PRELOAD images before .. Playing the animaton!

Please someone Help me:sign0085:
How to do?

I have:
B4X:
....
Sub Globals

   Dim ImageView1 As ImageView
   Dim TimerMario As Timer
   Dim ImageCounterVar As Int
   Dim AnimationImagesNumbers() As String
   AnimationImagesNumbers = Array As String ("00","01", "02", "03", "04", "05", "06", "07", "08", "09", "10")
   ImageCounterVar = 0
   Dim AnimationImagesNumbersMax As Int
   Dim labCONTROL As Label
End Sub



Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("screen1")
   AnimationImagesNumbersMax = 10 'How many images is the PGN set is the same of: AnimationImagesNumbers.Length ?
   TimerMario.Initialize("TimerMario", 5) 'show it in 1 sec
   TimerMario.Enabled = True
End Sub



Sub TimerMario_Tick
   If ImageCounterVar <= AnimationImagesNumbersMax Then
      ImageView1.Bitmap  = LoadBitmap(File.DirAssets, "image-00"&AnimationImagesNumbers(ImageCounterVar)&".png")
      ImageCounterVar = ImageCounterVar + 1
   Else If ImageCounterVar > AnimationImagesNumbersMax Then
      ImageCounterVar = 0 ' start again from 0
   End If
   TimerMario.Enabled = True
End Sub
....

How to PRELOAD these images for animations?
image-0000.png to image-0010.png
 
Top