I have put together a small SDL2 Android app that moves 6 small sprites across the screen - from left to right, right to left, repeat. I noticed that each sprite would occasionally stutter, so I have used the code from the lazyfoo Capping Frame Rate tutorial to prevent this. I also changed sprite movement from this:
enemy.position.x += enemy.velocity.x;
enemy.position.x += enemy.velocity.x * deltaTime;
I calculate deltaTime like this:
Uint64 NOW = SDL_GetPerformanceCounter();
Uint64 LAST = 0;
double deltaTime = 0;
// this bit goes in the main loop
LAST = NOW;
NOW = SDL_GetPerformanceCounter();
deltaTime = ((NOW - LAST)*1000 / (double)SDL_GetPerformanceFrequency() );
After both these changes however, the stuttering is even worse! I know that my target device (Alcatel Pixi 3 (8)) is pretty weedy, but I installed some simple 2D sprite based games written in C++ that have particle explosions, and I don’t see any stuttering at all in those.
And here’s the apk: https://www.dropbox.com/s/6j9i10g116hfa2b/app-debug.apk
Thanks in advance for any help you can provide.