Android Question How to change value in sprite?

herryj

Member
Licensed User
Longtime User
I am using same variable upon assigning the sprite image. On first load img1 assign first on sprite on the next load img2 should assign in the sprite variable. Though I have this bug, upon the 2nd loading img2 didn't show up.

Can anyone help me on how to change the value of the sprite variable?

Looking forward on your response.
 

herryj

Member
Licensed User
Longtime User
Code for the button
B4X:
Dim send As Button
        send=Sender
         If send.Tag=0 Then
        CallSubDelayed2(PlayTime,"easy",1)
    Else If send.Tag=1 Then
        ToastMessageShow("stage2",False)
        CallSubDelayed2(PlayTime,"easy",2)

Code for the (CallSubDelayed2(PlayTime,"easy",1)) Sub called

B4X:
Sub easy(ch As Int)
    gfx.EasyLevels(ch) : gfx.easyBasis(ch)

Code for the sprite handler

B4X:
Sub EasyLevels(el As Int)
el11.Bitmap=LoadBitmap(File.DirAssets,"easy.png")
el12.Bitmap=LoadBitmap(File.DirAssets,"easy1.png")
Select el
Case 1  : For i = 0 To el1.Length - 1
            el1(i).Bitmap = el11.Bitmap
            'firstRowImages(i).Region(imgWidth * i, 0dip, imgWidth, imgHeight)
            el1(0).Region(302,200,168,180) : el1(0).Position(20.5%x,52.25%y) ': el1(0).Height=10%y : el1(0).Width=10%y
            el1(1).Region(188,200,100,102) :  el1(1).Position(29%x,68%y) ': el1(1).Height=10%y : el1(1).Width=10%y
            el1(2).Region(6,200,168,102) : el1(2).Position(55%x,68%y) ': el1(2).Height=10%y : el1(2).Width=10%y
            el1(3).Region(387,6,83,102) :  el1(3).Position(80%x,68%y) ': el1(3).Height=10%y : el1(3).Width=10%y
            el1(4).Region(171,6,202,180) :  el1(4).Position(59%x,52.25%y) ': el1(4).Height=10%y : el1(4).Width=10%y
            el1(5).Region(6,6,151,128) :  el1(5).Position(85%x,55%y) ': el1(5).Height=10%y : el1(5).Width=10%y
            el1(i).MidAnchor : el1(i).Visible=False
        Next
Case 2 : For i = 0 To el1.Length - 1
            el1(i).Bitmap = el12.Bitmap
            'firstRowImages(i).Region(imgWidth * i, 0dip, imgWidth, imgHeight)
            el1(0).Region(302,200,168,180) : el1(0).Position(67%x,70%y) :  el1(0).Rotate=225
            el1(1).Region(188,200,100,102) :  el1(1).Position(24%x,80%y) :  el1(1).Rotate=90
            el1(2).Region(6,200,168,102) : el1(2).Position(18%x,70%y) : el1(2).Rotate=90
            el1(3).Region(387,6,83,102) :  el1(3).Position(24%x,80%y) : el1(3).Rotate=-140
            el1(4).Region(171,6,202,180) :  el1(4).Position(45%x,90%y) : el1(4).Rotate=-100
            el1(5).Region(6,6,151,128) :  el1(5).Position(34.5%x,80%y) :  el1(5).Rotate=150
            el1(i).MidAnchor :'el1(i).Visible=False
        Next

I have this separate code that goes back to the button in order to click the button and triggered the 2nd img on sprite
 
Upvote 0
Top