I've been trying to get this to work for a while now, and i dont know what the problem is...I can draw animations for some reason, but if i try to draw a simple static texture, nothing. I just want to draw a sprite at given coordinates and have a box2d body for collisions. I can get the body to work too, just not the texture. right now, I am trying to rebuild the whole thing, but still no progress. my object is
public class RoadBlock extends Sprite {
private TextureAtlas atlas;
public RoadBlock (PlayScreen screen, float x, float y) {
atlas = new
TextureAtlas(Gdx.files.internal("tunnelPics/tunnelAtlas.atlas"));
setPosition(x, y);
setRegion(atlas.findRegion("barbSmol"), 0, 0, 120, 75);
}
public void draw(Batch batch) {super.draw(batch);}
}
In the level it's drawn as
public void render(MyGdxGame game){
for(Sprite RB: RBs) {
RB.draw(game.batch);
}
}
this populates RB (an arrayList) from the tiled TMX map objects that relate to the sprites.
then in when rendering in the playScreen, i use
public void render(float delta) {
update(delta);
//background color
Gdx.gl.glClearColor(0,0,0,1);
Gdx.gl.glEnable(GL20.GL_BLEND); //enable transparent images
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//render
renderer.render();
game.batch.enableBlending();
game.batch.setProjectionMatrix(gamecam.combined);
game.batch.begin();
//render character
player.draw(game.batch);
//render current level
curLevel.render(game);
game.batch.end();
}
this calls the render function from above.