Android Question Rotate Animation (Lucky wheel)

Douglas Farias

Expert
Licensed User
Longtime User
Hi.
how can i rotate a imageview on b4a to make a lucky wheel?
I m tryed with canvas and with animation lib but not success.

With Animation lib
B4X:
anime.InitializeRotateCenter("",0,360,cvroleta)
anime.RepeatCount = -1
anime.Duration = 1000
anime.Start(cvroleta)

Problem
There is an effect of going slowly stopping.
Dont rotate for ever, have a effect when will start again. like fade in and fade out.



With Canvas and Timer
B4X:
#Region  Project Attributes
    #ApplicationLabel: Roleta
    #VersionCode: 1
    #VersionName:1
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Process_Globals
    Private t As Timer
    Private b As Bitmap
End Sub

Sub Globals
    Private angulo As Int
    Private rec As Rect
    Private cvroleta As Canvas
    Private pcvroleta As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
   
    b.Initialize(File.DirAssets, "valores.png")
   
    pcvroleta.Width = b.Width
    pcvroleta.Height = b.Height
   
   
    cvroleta.Initialize(pcvroleta)
    rec.Initialize(0,0,b.Width,b.Height)
    cvroleta.DrawBitmap(b,Null,rec)
    t.Initialize("t",1)
    angulo = 0
    t.Enabled = True

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub t_tick
    angulo = angulo + 1
    If angulo = 360 Then
        angulo=0
    End If
    cvroleta.DrawBitmapRotated(b,Null,rec,angulo)
    Activity.Invalidate
End Sub


Problem
With canvas its very slow for Android, on B4J its ok with a timer and a simple DrawImageRotated
But on b4a the rotate animation with a timer its very slow, debug and release.
The timer its with 1ms and the animation its very slow.

Here a example for b4j (very slow for android)
https://www.b4x.com/android/forum/threads/lucky-wheel-source-code.66638/


How can i make view rotate for ever? canvas dont work and animation have end effect.

Thx
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…