Sprite global/local 2. version

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by duschman.

Hi, to my posting before, I tried a second version
but that results in a PureBasic crash:

I wrote the two procedures together like:

Procedure SetCounter()
CreateSprite(20,18,22,0)
CreateSprite(21,18,22,0)
CreateSprite(22,18,22,0)
CreateSprite(23,18,22,0)
For i = 0 To 9
filename.s = "images\count" + Str(i) + ".bmp"
LoadSprite(i,filename,0)
Next
timecount = 1440
While timecount > 0
counter.s = Str(timecount)
;counter.s = LSet(counter,3,"0")
count1 = Val(Mid(counter,1,1))
count2 = Val(Mid(counter,2,1))
count3 = Val(Mid(counter,3,1))
count4 = Val(Mid(counter,4,1))

CopySprite(count1,20,0)
CopySprite(count2,21,0)
CopySprite(count3,22,0)
CopySprite(count4,23,0)

DisplaySprite(20,510,550)
DisplaySprite(21,530,550)
DisplaySprite(22,550,550)
DisplaySprite(23,570,550)
timecount = timecount - 1
Delay(50)
Wend

EndProcedure

to eliminate the problem of having sprite objects within two different procedures / threads

I call it with
tc_thread = CreateThread(@SetCounter(),0)


Any ideas what went wrong?