public void render(SpriteBatch sb) { Color color = sb.getColor(); sb.setColor(color.r, color.g, color.b, alpha); sb.draw(texture, x, y); sb.setColor(color); }
public LibGdxGraphics(GameWrapper gameWrapper, SpriteBatch spriteBatch, PolygonSpriteBatch polygonSpriteBatch, ShapeRenderer shapeRenderer) { super(); this.gameWrapper = gameWrapper; this.spriteBatch = spriteBatch; this.shapeRenderer = shapeRenderer; this.polygonSpriteBatch = polygonSpriteBatch; this.windowWidth = Gdx.graphics.getWidth(); this.windowHeight = Gdx.graphics.getHeight(); defaultTint = spriteBatch.getColor(); if (defaultTint != null) { font = new BitmapFont(true); } tint = defaultTint; lineHeight = 1; color = Color.WHITE; backgroundColor = Color.BLACK; colorTextureCache = new ShapeTextureCache(); translationX = 0; translationY = 0; scaleX = 1f; scaleY = 1f; rotation = 0f; rotationX = 0f; rotationY = 0f; /* Create Ortho camera so that 0,0 is in top-left */ camera = new OrthographicCamera(); }
public void draw(SpriteBatch batch) { if(angry) { defaultColor = batch.getColor(); batch.setColor(Color.RED); batch.draw( texture, enemyBody.getPosition().x - (ENEMY_WIDTH * .5f), enemyBody.getPosition().y - (ENEMY_HEIGHT * .5f), ENEMY_WIDTH, ENEMY_HEIGHT); batch.setColor(defaultColor); } else { batch.draw( texture, enemyBody.getPosition().x - (ENEMY_WIDTH * .5f), enemyBody.getPosition().y - (ENEMY_HEIGHT * .5f), ENEMY_WIDTH, ENEMY_HEIGHT); } } }
Color oldColor = batch.getColor(); batch.setColor(emitter.color); batch.draw(emitterTexture,
oldColor.set(batch.getColor());