i want to have an animation in my app. i create that and it works correctly, But I am not sure if my method is correct or not.
i repeate this code more by pressing Btnpress and i think it is not correct to Initialize pnlanimation every time.
thanks for your suggestion.
i repeate this code more by pressing Btnpress and i think it is not correct to Initialize pnlanimation every time.
thanks for your suggestion.
B4X:
Sub Begin
pnlmainanimat.Initialize("")
Root.AddView(pnlmainanimat,Root.Width/1.2,Root.Width/8,Root.Width/6,Root.Height/2)
End Sub
Sub TonAnimation
For i=0 To pnlanimation.Length-1
pnlanimation(i).Initialize("")
pnlmainanimat.AddView(pnlanimation(i),pnlmainanimat.Width/(Rnd(5,25)),pnlmainanimat.Height/1.5,pnlmainanimat.Width/9,pnlmainanimat.Width/9)
pnlanimation(i).SetBackgroundImage(LoadBitmap(File.DirAssets,"note_"&Rnd(2,4)&".png"))
moveview(pnlanimation(i),Rnd(4000,6000))
Next
End Sub
Sub moveview(View As B4XView, Duration As Int)
Dim Delta As Int = 20dip
View.SetLayoutAnimated(Duration / 5, View.Left+Delta*(Rnd(1,5)) , View.top-Delta*10, View.width, View.height)
View.SetVisibleAnimated(1000,False)
View.RemoveAllViews
End Sub
Sub Btnpress_Click
TonAnimation
End Sub