java - Objects getting jerks when moving camera in downward direction -


i have been making game in there number of objects in negative 'y' had taken arraylist , moving main character in downward direction.but when camera move character objects not moving smooth, getting jerks after interval of time.the code following

@override public void create() {     camera = new orthographiccamera(480, 720);     camera.position.set(480 / 2, 720 / 2, 0);     batch = new spritebatch();     int i;      this.baloonarrlist = new arraylist<baloon>();      (i = 0; < 3000; += 300) {         baloon baloon = new baloon(200, i);         baloonarrlist.add(baloon);         system.out.println(baloon.balloon_y);     }     texture1 = new texture(gdx.files.internal("data/sheet_final.png"));     textureregion1 = new textureregion(texture1, 561, 156, 115, 101); }  @override public void render() {      glcommon gl = gdx.gl;     gdx.gl.glclearcolor(1, 1, 1, 1);     gl.glclear(gl10.gl_color_buffer_bit);      camera.position.y += 4;     camera.update();     batch.setprojectionmatrix(camera.combined);     batch.begin();     int len = baloonarrlist.size();      (int = 0; < len; i++) {         batch.draw(textureregion1, baloonarrlist.get(i).balloon_x,                 baloonarrlist.get(i).balloon_y, 100, 100);     }      batch.end();  } 

so, how can make motion of objects smooth.

i believe source of issue following line:

camera.position.y += 4; 

you should instead change smaller value, or better, make based on speed of frame rate:

camera.position.y += 4 * gdx.graphics.getdeltatime(); 

this way camera move in y direction 4 pixels every second, instead of 4 pixels every frame. (of course may need increase 4 make faster, keep quite smooth.)


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -