So I've learned how to make a bunch of bitmaps fly out of the center of the screen using the SetLayoutAnimated method and a timer.
What I'd like to do next is move a bitmap along a spiral path starting from the center of the screen. Any ideas on how to accomplish this without using thousands of SetLayoutAnimated method in a loop?
Sub Process_Globals
Private fx As JFX
Dim l As Label
Dim s As Float
Dim r As Float
Dim cx,cy As Int
Dim t As Timer
End Sub
Sub AppStart (Form1 As Form, Args() As String)
Form1.Show
l.Initialize("")
l.Text="x"
Form1.RootPane.AddNode(l,0,0,10,10)
cx=Form1.Width/2
cy=Form1.Height/2
t.Initialize("update",1000/60)
t.Enabled=True
End Sub
Sub update_Tick
r=r+.3
s=s+.1
l.Left=cx+Sin(s)*r
l.Top=cy+Cos(s)*r
End Sub
THANK YOU!
I'm guessing what you are doing is putting a bitmap on a form and then using the timer to move that form around.
I'll translate this into B4A, which I don't think will be difficult.
MUCH APPRECIATION!
Hey @sorex -
The following code causes my bitmap to start in the center small (yes that is what I want) but it then moves diagonal down toward the bottom right corner as it grows.
Ideas?
B4X:
Private Sub animaSpiralTimer_Tick
If imvSpiralHeart.Height>=imvBiggestTestFor Then
imvSpiralHeart.Visible=False
imvSpiralHeart.Enabled=False
animaLinearTimer.Enabled = False
Else
spiral_r = spiral_r + 0.3
spiral_s = spiral_s + 0.1
imvHeartWidth = imvHeartWidth + 10dip
imvHeartHeight = imvHeartHeight + 10dip
imvSpiralHeart.left = spiral_x + Sin(spiral_s) * spiral_r
imvSpiralHeart.top = spiral_y + Cos(spiral_s) * spiral_r
imvSpiralHeart.Width=imvHeartWidth
imvSpiralHeart.Height=imvHeartHeight
End If
End Sub