I'm still trying to understand how to write the code to make my image rotate. I've been looking at examples but have some questions.
Regarding InitializeRotateCenter(), the docs say this:
InitializeRotateCenter (EventName As String, FromDegrees As Float, ToDegrees As Float, View As android.view.View)
Similar to InitializeRotate, with the pivot set to the given view's center.
Argument 1: I want to click on a button to rotate my directional gyro 1 degree (out of 360), so I am passing the "btnVORLeft" string which is my Left button object name.
Argument 2: I'm not sure what this means. FromDegrees from what reference point on the compass? If I enter 5 does that mean my directional gyro will move from the 5 degree point on a compass? I have 5 input.
Argument 3: ToDegrees would mean how much I want the image to rotate. So if I want 1 degree per click and I specify FromDegrees as 5 then ToDegrees would be 6? I have 6 input.
Argument 4: I input my panel object (pnlVOR) that holds my directional gyro image.
When I run my code, I click on the Left VOR button and I see my directional gyro compass flicker, and it doesn't do that until I release the mouse button.
The behavior I'm looking for is one button click to rotate the compass 1 degree and stay there. I read somewhere (I can't find it again) that with an image, you can rotate it, but it won't stay rotated. That capability doesn't exist. Or has that been updated? I think I read that in a post that was 2 years old.
I also read that I might need to forget using an image to do this and use a drawing bit map to move the compass and have it remain at it's new position?
Here is my current B4A code:
#Region Project Attributes
#ApplicationLabel: Holding Patterns
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim pnlVOR As Panel
Dim Rotation As Animation
Private btnVORLeft As Button
Private btnVORRight As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("VOR")
pnlVOR.SetBackgroundImage(LoadBitmapSample(File.DirAssets, "dg6b.jpg", pnlVOR.Width, pnlVOR.Width))
Rotation.InitializeRotateCenter("btnVORRight", 0, 1, pnlVOR)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnVORLeft_Click
End Sub
Sub btnVORRight_Click
Try
Rotation.Start(pnlVOR)
Catch
Log(LastException.Message)
End Try
End Sub