I've been trying to record some gameplay footage of the game I'm currently working on, using the Android SDK and ADB to do it.
Whilst the game runs at constant 60 fps in my medium-end phone, as soon as i start recording, it drops to around 50-55 fps, but always inconsistent. Now, I know that screen recording does "push" harder for the phone and thus may bring the fps down, but I'm worried that, because of this behavior, lower end smartphones will also have these lag issues - which shouldn't happen, as it's a relatively straight forward 2D game.
After performance testing for a while, I figured out that the major cause of lag are the "background elements": being a side-scroller, I have a list that holds 4 of these background elements (which are just textures retrieved from an atlas). As the camera goes further, I then update the position of those textures, so they also appear further, like so:
private List<Mountain> mountains;
// ...
mountains = new ArrayList<Mountain>(4);
for (int i = 0; i < 4; i++) {
mountainPos = new Vector2(20 + 100 * i, 150);
mountainColor = Color.BLACK;
mountains.add(new Mountain(
mountainPos, 350, 250, "texturePath", mountainColor));
// ...
// On the update method, I update the positions.
for (int i = 0; i < 4; i++) {
// If the mountain can't be seen by the camera...
if (hero.getPosition().x - mountains.get(i).getPosition().x >= 500) {
highestMountainX += 100;
mountains.get(i).setPosition(new Vector2(
highestMountainX,
mountains.get(i).getPosition().y)
));
}
}
// ...
// On the render method
for (int i = 0; i < 4; i++)
mountains.get(i).render(batch);
So, this leaves me with two questions:
1. Roughly, should I be worried about lag issues on lower-end smartphones, considering the fps drops I get while recording in my medium-end one?
2. The sprites I mention above are 350x250 pixels, and are rendered with that same width and height (350 and 250, respectively). Is the position updating method above inefficient? Any optimizations I could do?
Thanks in advance.
EDIT 1: Not sure if this is relevant, but the spritebatch's total render calls, everytime the render method is called, ranges from 4 to 14 (during the play state).