graphics - TextureRegion cuts texture in a wrong way -
i want have background texture 3 rectangles , want create animation them, - texture
but first rectangle cuts in proper way , 2 others cut in dumb way proper way, dumb way #1, dumb way #2
here code.
public class mainmenu implements screen{ texture background_main; textureregion[] background_textures; animation background_animation; spritebatch batch; textureregion current_frame; float statetime; bobdestroyer game; orthographiccamera camera; public mainmenu(bobdestroyer game){ this.game = game; } @override public void show() { camera = new orthographiccamera(); camera.settoortho(true, gdx.graphics.getwidth(), gdx.graphics.getheight()); batch = new spritebatch(); background_main = new texture(gdx.files.internal("main_menu_screen/background.png")); background_textures = new textureregion[3]; for(int = 0; i<3; i++){ background_textures[i] = new textureregion(background_main,0, 0+72*i, 128, 72+72*i); } background_animation = new animation(2f,background_textures); } @override public void render(float delta) { gdx.gl.glclear(gl20.gl_color_buffer_bit | gl20.gl_depth_buffer_bit); statetime += gdx.graphics.getdeltatime(); current_frame = background_animation.getkeyframe(statetime, true); batch.begin(); batch.draw(current_frame,0, 0,gdx.graphics.getwidth(),gdx.graphics.getheight()); batch.end(); } }
if understand correctly, trying create 3 textureregions of same width/height? if yes, issue may with:
new textureregion(background_main,0, 0+72*i, 128, 72+72*i)
i think you'd want:
new textureregion(background_main,0, 0+72*i, 128, 72)
as 128x72 width/height (not x/y positions) of next textureregions, , not want them same height (72) opposed varying heights (72+72*i)?
Comments
Post a Comment