Change Stage Background Color

Anything libgdx related goes here!

Change Stage Background Color

Postby tcms » Tue Feb 03, 2015 4:24 pm

Hello guys

It's possible to change the background color of the stage?! Without setting Gdx.gl.glClearColor.

I know that an alternative way is add an Image with the size of the stage and change it's color, but I don't think that is the best approach.

Cheers
tcms
 
Posts: 24
Joined: Tue Dec 09, 2014 2:06 am

Re: Change Stage Background Color

Postby evilentity » Tue Feb 03, 2015 8:47 pm

There is no "background". The background is whatever color the screen is cleared with. You know how to set that...
You could make a box with shaperenderer, but this will be slower and have no benefit over just clearing the screen with color you want.
Tinting some image will allow you to have some texture, to your super boring flat background.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4867
Joined: Wed Aug 24, 2011 11:37 am

Re: Change Stage Background Color

Postby tcms » Wed Feb 04, 2015 1:24 am

evilentity wrote:There is no "background". The background is whatever color the screen is cleared with. You know how to set that...
You could make a box with shaperenderer, but this will be slower and have no benefit over just clearing the screen with color you want.
Tinting some image will allow you to have some texture, to your super boring flat background.


So, the best way to do it ( at least more efficient) is to set a new Gdx.gl.glClearColor??

cheers
tcms
 
Posts: 24
Joined: Tue Dec 09, 2014 2:06 am

Re: Change Stage Background Color

Postby evilentity » Wed Feb 04, 2015 2:45 am

Thats the usual way.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4867
Joined: Wed Aug 24, 2011 11:37 am

Re: Change Stage Background Color

Postby tcms » Wed Feb 04, 2015 2:50 am

The problem is I'm using fitViewport, so the bars will have the same color has background
tcms
 
Posts: 24
Joined: Tue Dec 09, 2014 2:06 am

Re: Change Stage Background Color

Postby evilentity » Wed Feb 04, 2015 3:10 pm

So stop being lazy and make actual background for your thing?
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4867
Joined: Wed Aug 24, 2011 11:37 am

Re: Change Stage Background Color

Postby tcms » Wed Feb 04, 2015 4:32 pm

Ok, i think you don't understand what I want. You know the game borderline?
tcms
 
Posts: 24
Joined: Tue Dec 09, 2014 2:06 am

Re: Change Stage Background Color

Postby svensk » Sun Feb 09, 2020 3:48 pm

shapeRenderer can be used.
in create:
Code: Select all
 renderer = new ShapeRenderer();

in render:
Code: Select all
      renderer.begin(ShapeType.Filled);
      renderer.setColor(Color.DARK_GRAY);
      renderer.rect(0, 0, mainStage.getViewport().getWorldWidth(), mainStage.getViewport().getWorldHeight());
      renderer.end();
svensk
 
Posts: 3
Joined: Sat Oct 12, 2019 5:27 pm


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 1 guest