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
mMano.SetLayoutAnimated (MDURATION_Animation_1, x, y, mMano.Width, mMano.Height)
Sleep(MDURATUON_Animation_1)
mMano.SetLayoutAnimated (MDURATION_Animation_2, x, y, mMano.Width, mMano.Height)
Sleep(MDURATUON_Animation_2)
mMano.SetLayoutAnimated (MDURATION_Final, x, y, mMano.Width, mMano.Height)
Sleep(MDURATUON_Final)
Please note that sometimes the SetLayoutAnimation animations do not seem to start right away, and the Sleep of the same duration does not seem to be enough to make the animation visible.
I would also add a 100 or 200 milliseconds more
unfortunately it does not work because the code is not exactly like that,
the animation is set inside a sub called by another sub
and sleep causes the diver to exit immediately
the example closest to my code is this
B4X:
public sub test
Animation (2000,100,100)
Animation (2000,300,200)
......
end sub
private sub Animation (duration as long, X as int, Y as int)
mMano.setLayountAnimatio (duration, X, Y, mMano.width, mMano.heigth)
end sub
due to the complexity of the calling code, inserting sleep is not "simple" because the Animation sub is inserted in what will be a library
Sorry to say but it is a very bad code and should never be used.
You need to learn how to use resumable subs that return value. Watch the resumable subs video tutorial: https://www.b4x.com/etp.html
Simple solution:
B4X:
public sub test
Animation (2000,100,100)
Sleep(2000)
Animation (2000,300,200)
Sleep(200)
......
end sub
private sub Animation (duration as long, X as int, Y as int)
mMano.setLayountAnimatio (duration, X, Y, mMano.width, mMano.heigth)
end sub
If you want to sleep inside the Animation sub:
B4X:
public sub test
Wait For (Animation (2000,100,100)) Complete (Unused As Boolean)
Wait For (Animation (2000,200,300)) Complete (Unused As Boolean)
......
end sub
private sub Animation (duration as long, X as int, Y as int) As ResumableSub
mMano.setLayountAnimatio (duration, X, Y, mMano.width, mMano.heigth)
Sleep(Duration)
Return True
end sub
Note: @Erel's 2nd example left out the sleep inside the Animation sub (mentions it, just left it out)
B4X:
public sub test
Wait For (Animation (2000,100,100)) Complete (Unused As Boolean)
Wait For (Animation (2000,200,300)) Complete (Unused As Boolean)
......
end sub
private sub Animation (duration as long, X as int, Y as int) As ResumableSub
mMano.setLayountAnimatio (duration, X, Y, mMano.width, mMano.heigth)
Sleep(200)
Return True
end sub
Sorry to say but it is a very bad code and should never be used.
You need to learn how to use resumable subs that return value. Watch the resumable subs video tutorial: https://www.b4x.com/etp.html
Simple solution:
B4X:
public sub test
Animation (2000,100,100)
Sleep(2000)
Animation (2000,300,200)
Sleep(200)
......
end sub
private sub Animation (duration as long, X as int, Y as int)
mMano.setLayountAnimatio (duration, X, Y, mMano.width, mMano.heigth)
end sub
If you want to sleep inside the Animation sub:
B4X:
public sub test
Wait For (Animation (2000,100,100)) Complete (Unused As Boolean)
Wait For (Animation (2000,200,300)) Complete (Unused As Boolean)
......
end sub
private sub Animation (duration as long, X as int, Y as int) As ResumableSub
mMano.setLayountAnimatio (duration, X, Y, mMano.width, mMano.heigth)
Return True
end sub
how about using a timer and a list with this type (object,left,top,width,height)
and using .SetLayout at a tick event and remove the entry from list. https://en.wikipedia.org/wiki/Linear_interpolation
the problem is always the same
sleep returns control to the flow of commands
I need only the "drawing" to be updated in the positions of the animation without the flow passing to the control that sets the successive animations
how about using a timer and a list with this type (object,left,top,width,height)
and using .SetLayout at a tick event and remove the entry from list. https://en.wikipedia.org/wiki/Linear_interpolation