Speed and resume...

skipsy

Member
Licensed User
Longtime User
Hello,

In fact I have 2 questions concerning the file I have attached.
This is a small program with boucing balls.

First, it looks very slow and the moves are not smooth !!!
Concerning smooth, I it is better when I change the timer tick for a smaller
value but I guess it cost for other running apps.
Is Android so slow, is it B4A, the CPU or my program ?

Another problem : If I swap to another application and return to this one
it crashes (Java exception...). I guess there is someting to do in
Activity_pause and Activity_resume but I don't understand what. I thought
it could be due to lost variables but all variables look OK from the debugger !!

Any idea ???
Thks a lot
William.
 

Attachments

  • Balls.zip
    58.7 KB · Views: 241

pluton

Active Member
Licensed User
Longtime User
The error is happening when you want return into app on resume line:

B4X:
Sub Activity_Resume
   TIMER1.Enabled = True
End Sub

Debugger says: Interval must be larger than 0
Why don't you remove line "If FirstTime Then..." and remove everything in Sub Activity_Resume ??

sc3.png
 
Last edited:
Upvote 0

skipsy

Member
Licensed User
Longtime User
Hello,

Good idea but I get the same error message so I did something else : I have removed
IF THEN and END IF
I have no more crash but when I am back to the program balls position has
changed. The positions are not saved !!

Best regards,
William.
 
Upvote 0

skipsy

Member
Licensed User
Longtime User
The emulator is slow. Try it on a real device.

Hi,
Sorry I forgot to mention that I did those test on the real device (HTC desire S)

I have downloaded some very fast games. Iam not sure they have been
developped with a language like B4A or JAVA (?)
Android is Linux based. I am wondering if there is any other way to devellop
bypassing android layer (?????).

Best regards,
William
 
Upvote 0

ssg

Well-Known Member
Licensed User
Longtime User
Aloha... my favourite topic.. bouncing balls...

1 - to speed up, make the balls move more than 1 pixel at a time... try changing it to 5... dont reduce the timer as it can somehow cause more jaggyness...

2 - the error you're getting with timer... you need to declare your timer in process_globals. Then on activity_create, check first time and initialise the timer there. if you wanna keep store of where your variables are at, then you need to declare your variables in global too...

got it?
 
Upvote 0

skipsy

Member
Licensed User
Longtime User
Great !!

I have moved timer declaration to process_global. No more error message
and when Iam back to the program, balls are at the same positions.

concerning the speed I already did a test with a step to 4dips but the move
is not smooth... Well, I must choose.

Thks for your help;
WW
 
Upvote 0
Top