java - libgdx rendering srite over another causes background sprite to disapear -
image of problem http://imgur.com/znphiiu succesfully rendered background game , tried render sprites on top of , screen gets messed big blue l.
code main
public class wizardgame extends game { public static final string title = "are bad enough wizard save princess?!", verision = "0.0.0.0.prealpha"; playtest pt = new playtest(); private fpslogger fps; public void create() { gdx.gl20.glclearcolor(0, 0, 0, 1); gdx.gl20.glclear(gl20.gl_color_buffer_bit); fps = new fpslogger(); fps.log(); pt.create(); } public void dispose() { super.dispose(); } public void render() { super.render(); pt.render(); } public void resize(int width, int height) { super.resize(width, height); } public void pause() { super.pause(); } public void resume() { super.resume(); }
}
playtest code
public class playtest implements screen { private textureatlas atlas; private atlasregion floor; private spritebatch batch; private orthographiccamera camera; private sprite background; private bitmapfont font; private string fps; blocks block = new blocks(); public void render() { gdx.gl20.glclearcolor(0, 0, 05, 1); gdx.gl20.glclear(gl20.gl_color_buffer_bit); batch.begin(); background.setbounds(0, 0, 720, 1280); background.draw(batch); block.renderblocks(); batch.end(); } public void resize(int width, int height) { // todo auto-generated method stub } public void show() { } public void hide() { } public void pause() { } public void resume() { } public void dispose() { atlas.dispose(); batch.dispose(); } public void create() { atlas = new textureatlas(gdx.files.internal("data/wizardpack.pack")); floor = atlas.findregion("backfloor"); background = new sprite(floor); batch = new spritebatch(); font = new bitmapfont(gdx.files.internal("data/magicdebug48.fnt")); block.create(); } @override public void render(float delta) { // todo auto-generated method stub }
}
block code
public class blocks extends game { private textureatlas atlas; private spritebatch batch; private atlasregion sword,shield,staff,fireball,iceball; private sprite sprsword,sprshield,sprstaff,sprfireball,spriceball; @override public void create() { atlas = new textureatlas(gdx.files.internal("data/wizardpack.pack")); batch = new spritebatch(); sword = atlas.findregion("sword"); shield = atlas.findregion("shield"); staff = atlas.findregion("staff"); fireball = atlas.findregion("flame"); iceball = atlas.findregion("icespell"); sprsword = new sprite(sword); sprshield = new sprite(shield); sprstaff = new sprite(staff); sprfireball = new sprite(fireball); spriceball = new sprite(iceball); } public void renderblocks(){ gdx.gl20.glclearcolor(0, 0, 05, 1); gdx.gl20.glclear(gl20.gl_color_buffer_bit); batch.begin(); batch.draw(sword, 0, 0, 0, 0, 32, 32, 1, 1, 0); //sprshield.setbounds(15, 15, 32, 32); // sprshield.draw(batch); batch.end(); } public void dispose(){ atlas.dispose(); batch.dispose(); }
}
i fixed :d call renderblocks has after end of batch.
Comments
Post a Comment