Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 4:54 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Jul 12, 2012 12:38 pm 
Offline
User avatar

Joined: Wed Jun 20, 2012 10:33 pm
Posts: 35
Location: Doncaster, South Yorkshire
I've made a program where a bar goes up and down the screen, and you have to press the spacebar when it's within a certain area.

For aesthetic purposes, I was wondering whether it's possible to make the 'area' more transparent than the bar underneath, so that you can still see the bar moving up and down?


Thanks! :)


Top
 Profile  
 
PostPosted: Fri Jul 13, 2012 11:33 am 
Offline
User avatar

Joined: Wed Jun 20, 2012 10:33 pm
Posts: 35
Location: Doncaster, South Yorkshire
I just need to make a shape slightly see-through.


Top
 Profile  
 
PostPosted: Fri Jul 13, 2012 11:39 am 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
Have you tried this?
Code:
colorAlpha = new Color(1f,1f,1f,0.5f);
...


g.setColor(colorAlpha);
g.fill(Shape)


Top
 Profile  
 
PostPosted: Fri Jul 13, 2012 12:58 pm 
Offline
User avatar

Joined: Wed Jun 20, 2012 10:33 pm
Posts: 35
Location: Doncaster, South Yorkshire
Ah, that looks like what I'm looking for! :D Could you possibly explain what it means?


Top
 Profile  
 
PostPosted: Fri Jul 13, 2012 1:06 pm 
Offline
User avatar

Joined: Fri Dec 24, 2010 3:06 am
Posts: 90
Location: USA, Texas
Delinitor wrote:
Ah, that looks like what I'm looking for! :D Could you possibly explain what it means?

Code:
Color colorAlpha = new Color(1f,1f,1f,0.5f);
Here you are creating a new color, which is white and is half transparent. The values that you pass to construct a new color are the red, green, blue, and alpha values of the color.
Code:
g.setColor(colorAlpha);
Here you are setting the color to use to draw graphics
Code:
g.fill(Shape)
Here you are filling a shape with the color you set earlier.
Do note though, that the color will be set for the rest of the draw calls, so you'll probably want to set the color back to solid white unless you want everything afterwards rendered at half opacity.


Top
 Profile  
 
PostPosted: Sat Jul 14, 2012 11:28 am 
Offline
User avatar

Joined: Wed Jun 20, 2012 10:33 pm
Posts: 35
Location: Doncaster, South Yorkshire
Thanks! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group