Secret power (of gameview)?

Quillok

Member
Licensed User
Longtime User
Hey,
I'm a little bit confused, I'm using B4A now since a year, before I was doing a lot with VB on Windows. But there are so much things I don't understand or I'm doing wrong.
At the moment I'm experimenting with gameview and I've discovered something, maybe for the most of you it's easy to explain, but I don't get it.

I try to show it with the example of Erels GameView Smiley app.

I didn't change much, only that I dim the timer in Globals:

B4X:
Sub Globals
   Dim gv As GameView
   Dim lblFPS As Label
   
   Dim timer1 As Timer '<-- new at this position
   timer1.Initialize("Timer1", 15) '<-- new at this position   
End Sub

Then I enable the timer at activity_create:

B4X:
Sub Activity_Create(FirstTime As Boolean)
'...
'...
'...
   Activity.AddView(lblFPS, 0, 100%y - 30dip, 50dip, 30dip)

   timer1.Enabled = True '<-- new at this position
End Sub

And the timer isn't disabled at activity_pause:

B4X:
Sub Activity_Pause (UserClosed As Boolean)
   'timer1.Enabled = False
End Sub

If I start it, everything works fine, If i leave the app with the back button (not home) and then start the app again, it's much faster as before but everything, besides of the speed, is working well.
So my problem is, why does this happen (are there with this code more than one timer working at a time?!) and is it possible to use it without restarting the app?

At the first start the fps on my Iconia Tab A700 were at 60, at the second start there were at 80, third start 90, then the changes doesn't make huge steps but it seems it's getting faster and faster...

I don't really understand it, but maybe some of you could explain me this, thanks in advance :)
 

Quillok

Member
Licensed User
Longtime User
Ok, a new timer is created and it works parallel to the one that's already running and both do the same and because of this it's running faster.

When I set the ticks for the timer from 15 to 5 it's not wokring much faster, but with this method there would be 2 timers and everything works faster. The CPU usage is increased but not so strong that it would drain the battery down in a moment... interesting thing...

I think I will experimenting a little bit more :)
 
Upvote 0
Top