Saturday, July 25, 2015

java - How can I add a transparent overlay to a UI in libGDX?


I am attempting to use the following code


        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(3,3,3,.3f);
shapeRenderer.rect(0,0,gameWidth,gameHeight);
shapeRenderer.end();


So that when the menu is accessed, a transparent background appears. The problem I am facing is that when I try to do this the objects rendered by the SpriteBatch seem to misbehave. Upon further research i found that attempting to nest that code within SpriteBatch.begin() and SpriteBatch.end() is the cause of that. However, If I try to place the code after the SpriteBatch.end(), because the SpriteBatch has ended the objects rendered by it do not appear behind the transparent rectangle. (I tried assigning SpriteBatch and Shaperender a different camera, however, that didn't fix the problem.) How can I fix this or find another way to implement the transparent background for the menu.




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...