Erel,
New thread and example code as suggested:
I'm having a problem with jerky animation. I've tried setting the hardware acceleration in the manifest but it doesn't seem to have any effect. Should this now be set in the project or activity attributes and if so how? I'm moving photographic images.
The animation also seems to have an adverse effect on timers where the time period can be, for example, stretched from 20mS to 80/ 90mS during the transition. Is that normal?
Code example:
The loop within timer3_tick illustrates the effect of other code running and makes the animation jerky. Enabling the 'DoEvents' solves it.
Timer1_tick shows the effect of the animation running has on that timer with the period varying up to four times its interval setting when the transition is happening.
Any suggestions please?
New thread and example code as suggested:
I'm having a problem with jerky animation. I've tried setting the hardware acceleration in the manifest but it doesn't seem to have any effect. Should this now be set in the project or activity attributes and if so how? I'm moving photographic images.
The animation also seems to have an adverse effect on timers where the time period can be, for example, stretched from 20mS to 80/ 90mS during the transition. Is that normal?
Code example:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim timer1 As Timer
Dim timer2 As Timer
Dim timer3 As Timer
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 image As Bitmap
Dim displayslide1 As ImageView
Dim displayslide2 As ImageView
Dim slidepanel As Panel
Dim animate1 As Animation
Dim animate2 As Animation
Dim thistime As Long
Dim lasttime As Long
Dim interval1 As Int = 20
Dim interval2 As Int = 1000
Dim interval3 As Int = 250
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")
timer1.Initialize("timer1",interval1)
timer2.Initialize("timer2",interval2)
timer3.Initialize("timer3",interval3)
timer1.Enabled = True
timer3.Enabled = True
slidepanel.Initialize("")
Activity.AddView(slidepanel,10dip,10dip,800dip,500dip)
displayslide1.Initialize("")
displayslide2.Initialize("")
displayslide1.Gravity = Gravity.FILL
displayslide2.Gravity = Gravity.FILL
slidepanel.AddView(displayslide1, 0dip, 0dip, slidepanel.width, slidepanel.height)
slidepanel.AddView(displayslide2,0dip, 0dip, slidepanel.width, slidepanel.height)
image.InitializeSample(File.DirRootExternal & "/Pictures/", "image1.jpg",slidepanel.width, slidepanel.height)
displayslide1.Bitmap = image
image.InitializeSample(File.DirRootExternal & "/Pictures/", "image2.jpg",slidepanel.width, slidepanel.height)
displayslide2.Bitmap = image
animate1.InitializeTranslate("animations",0,0,-slidepanel.Width,0)
animate1.duration = interval2
animate2.InitializeTranslate("",slidepanel.Width,0,0,0)
animate2.duration = interval2
animate1.Start(displayslide1)
animate2.start(displayslide2)
End Sub
Sub timer1_tick
thistime = DateTime.now
Log(thistime & " : " & (thistime - lasttime) & " : " & (thistime - lasttime - interval1))
lasttime = thistime
End Sub
Sub Animations_Animationend
Log("stop")
timer2.Enabled = True
End Sub
Sub timer2_tick
timer2.Enabled = False
Log("start")
animate1.Start(displayslide1)
animate2.start(displayslide2)
End Sub
Sub timer3_tick
For i = 0 To 5000
' DoEvents
Next
End Sub
The loop within timer3_tick illustrates the effect of other code running and makes the animation jerky. Enabling the 'DoEvents' solves it.
Timer1_tick shows the effect of the animation running has on that timer with the period varying up to four times its interval setting when the transition is happening.
Any suggestions please?