GLBasic forum

Main forum => GLBasic - en => Topic started by: ampos on 2011-May-18

Title: USESCREEN and transparent
Post by: ampos on 2011-May-18
I am using a sprite to draw my menu:

Code (glbasic) Select
USESCREEN -1
DRAWBACKGROUND()
USESCREEN 1
DRAWMENU()
USESCREEN -1
DRAWSPRITE 1,0,0
SHOWSCREEN


My problem is that I can not clear the sprite/menu and make it transparent. I want the zones in the menu_sprite not drawn to be transparent, so the background is shown under my menu_sprite.
Title: Re: USESCREEN and transparent
Post by: BigAnd on 2011-May-18
I think you have to clear your screen to the colour you use as transparent. By default its usually that bright purple (255,0,128).
Title: Re: USESCREEN and transparent
Post by: spacefractal on 2011-May-18
Look for the code on the help section.

I Did have same problem, but easy to do.

Just draw a rect using the transparency color. Then it's will clear with transparency.

Title: Re: USESCREEN and transparent
Post by: Slydog on 2011-May-18
Since the menu appears static, you could always include the background with the menu sprite, and only draw one sprite each frame.
Unless the background isn't static!

Code (glbasic) Select
USESCREEN 1
DRAWBACKGROUND()
DRAWMENU()
USESCREEN -1

WHILE TRUE
  DRAWSPRITE 1,0,0
  SHOWSCREEN
WEND
Title: Re: USESCREEN and transparent
Post by: ampos on 2011-May-18
The background is moving, but I just realize that I can draw the moving background on the menu sprite...

Anyway, I will try clearing the menu with 255,0,128... just for trying.

I tried before

clearscreen 0xff000000, 0xffffffff, 0x00000000, 0x00ffffff with some interesting results.
Title: Re: USESCREEN and transparent
Post by: spacefractal on 2011-May-18
dont use CLEARSCREEN command, its wont work very well, But instead you use DRAWRECT.

USESCREEN 2
SETTRANSPARENCY RGB(0,0,0)
DRAWRECT 0,0,999,999,RGB(0,0,0) // will draw black colour _AND_ transparent alpha

found from (I posted extractly or near the same as you):
http://www.glbasic.com/forum/index.php?topic=6233.0
Do the job.