if I have to use more commands like that
mMano.SetLayoutAnimated (MDURATION, x, y, mMano.Width, mMano.Height)
to create a complex animation you only see the last command
if I insert a sleep (0) the animations are reduced to some flashes in the beginning positions, except the last one
I'm sorry to contradict you, but on the contrary this is one of the few cases in which Sleep is necessary.
Do Event with the graphics or views conflicted. So putting a DoEvent with an asynchronous animation would have created unexplained crashes.
As you know I love the DoEvent, but unfortunately in this case I would not have used it.
Also I would have chosen the Timer because more precise than the Asynchronous events, I already tried in other libraries mine. Sometimes I preferred to create animations with Timer for better movements. Often SetAnimation tend to overlap effects and cancel each other out.
Only that I had the same problem in some of my libraries.
In this, the leftward movement was not equal to the right shift. Although it is the same animation but I was only changing to the direction. Moving to the right I used SetLayoutAnimated while left a Timer and then the animations look the same
I dealt with a problem created by System animations even with IPhone just yesterday in my XUIView library.
Use SetAnimatedLayout only if simple animations. Otherwise I use Timer, system resources with JavaObejct with Android or OBJC with IPhone.
#Region Project Attributes
#ApplicationLabel: UI Anim Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#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.
Private Label1 As Label 'a label in Layout1
Private Anim As Animation
Private Timer1 As Timer
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
Anim.Initialize
Anim.Clear
Dim x As Int
Dim y As Int
Dim w As Double
For w = 0.0 To 3600.0 Step 60.0/90.0
x = SinD(w)*50dip
y = CosD(w)*50dip
Dim A As AnimObj
A.Initialize
A.Obj = Label1
A.Left = 50%x + x
A.Top = 50%y + y
A.Width = Label1.Width
A.Height = Label1.Height
Anim.Add(A)
Next
Timer1.Initialize("Timer1",20)
Timer1.Enabled = True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Timer1_Tick
Anim.Tick
End Sub
class Animation:
B4X:
Sub Class_Globals
Type AnimObj (Obj As View,Left As Int,Top As Int,Width As Int,Height As Int)
Dim List1 As List
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
List1.Initialize
End Sub
Public Sub Clear
List1.Clear
End Sub
public Sub Add(Obj As AnimObj)
List1.Add(Obj)
End Sub
Public Sub Tick
If List1.Size = 0 Then Return
Dim Obj As AnimObj
Obj = List1.Get(0)
Dim ObjUI As View
ObjUI = Obj.Obj
ObjUI.Left = Obj.Left
ObjUI.Top = Obj.Top
ObjUI.Width = Obj.Width
ObjUI.Height = Obj.Height
ObjUI.Invalidate
List1.RemoveAt(0)
End Sub