I am trying to learn how display text with some time in between.
I tried a regular sub but it only returned the last item.
I looked at the forum and guessed that I ndeeded a Resumable Sub.
So I watched the video on Resumable Subs twice, then borrowed ImagesSameCanvas and tried to see if I could display the 4 images with 2 seconds in between.
If I call DRAWIT without the Wait For, all 4 images display but without the 2 second sleep.
If I call DRAWIT with the Wait For, only the first image displays.
If I step through the code in debug mode, nothing shows.
I know I am doing something wrong, but can't figure out what it is.
I have been trying for a while and it's time to ask for help.
The code is below.
Any suggestions?
I tried a regular sub but it only returned the last item.
I looked at the forum and guessed that I ndeeded a Resumable Sub.
So I watched the video on Resumable Subs twice, then borrowed ImagesSameCanvas and tried to see if I could display the 4 images with 2 seconds in between.
If I call DRAWIT without the Wait For, all 4 images display but without the 2 second sleep.
If I call DRAWIT with the Wait For, only the first image displays.
If I step through the code in debug mode, nothing shows.
I know I am doing something wrong, but can't figure out what it is.
I have been trying for a while and it's time to ask for help.
The code is below.
Any suggestions?
B4X:
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: ImagesSameCanvas
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim cvsActivity As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
cvsActivity.Initialize(Activity)
Dim i As Int
Dim imgW, imgH As Int
imgW = 50%x
imgH = imgW / 3 * 2 ' image ratio W/H = 3/2
For i = 0 To 3
'this shows all 4 images in the proper place, but no sleep
' drawit(i,imgW,imgH)
'this shows only the first image in the proper place
wait for (drawit(i,imgW,imgH)) complete (Result As Object)
'NOTE: In debug mode, nothing shows
Next
End Sub
Sub Activity_Resume
End Sub
Sub drawit(i As Int, imgW As Int, imgH As Int) As ResumableSub
Dim r As Rect
Dim x, y As Int
x = (i Mod 2) * imgW
y = Floor(i / 2) * imgH
r.Initialize(x, y, x + imgW, y + imgH)
cvsActivity.DrawBitmap(LoadBitmap(File.DirAssets, "image" & i & ".jpg"), Null, r)
Sleep(2000)
Return Null
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub