Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How do you make a 2D object translucent?

Author
Message
andycb
16
Years of Service
User Offline
Joined: 12th Jan 2008
Location:
Posted: 24th Feb 2008 17:21
How do you make a 2D object translucent because i am trying to make an energy bar for the HUD of my 3D game but it would help if you colud see through the energy bar so that you can better see where the enemy's are.

i probably haven't explained that very well so if you need more info on what i need ask.
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 24th Feb 2008 17:53
seems simple enough. SO by 2d object, im assuming you mean a sprite, or do you want a plane or somthing...

If its a sprite, i can help, but i stink at 3d, so ill stear clear of that...

If its a sprite, you want to change its alpha value. you can do that with an amazing command called, set sprite diffuse...
This next part is copied RIGHT out of the help files

This command will set the alpha value of the specified sprite. The alpha controls how much of the sprite is
present on screen and is used to create a translucent sprite. The Alpha value range is 0 to 255, with 255
being completely solid and 0 being invisible. The parameters should be specified using integer values.

Syntax

SET SPRITE ALPHA Sprite Number, Alpha Value


so, to use it, run somthing like this code.. ( im making this on the fly, but i think it should work)


Sorry for the wierdness of the text in that code by the way...
That should be what you need. Best of luck


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 24th Feb 2008 18:59
not actually working on dbpro as it is, but probably just needs some tinkering??
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 24th Feb 2008 19:01
OOPS another double post (again no patience for it to come through)

You've put
Set sprite diffuse

it SHOULD read:

Set sprite alpha

(you wrote it in your explanation but didnt actually use it)
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 24th Feb 2008 22:21
i ALWAYS do that... not even joking.


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 25th Feb 2008 00:28
sorry wasnt trying to sound out of place just thought might help to correct you on this occassion
andycb
16
Years of Service
User Offline
Joined: 12th Jan 2008
Location:
Posted: 25th Feb 2008 17:41
That works with sprites but what i meant was like a box so the code would be like


But i might be able to change the box so its a sprite instead. I'll have to see.

But thanks for the help anyway - especially if the energy bar still works once ive changed it to a sprite.
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 25th Feb 2008 22:04 Edited at: 25th Feb 2008 22:04
oh, cause you just devrease the boxes coridinates to show the lack of energy?
Hmm. I wonder if the stretch sprite command would help.


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/
andycb
16
Years of Service
User Offline
Joined: 12th Jan 2008
Location:
Posted: 26th Feb 2008 17:48
i checked out the stratch command and in the help bit it said that the stretch command couldn't have a value of 0 it had to always be 1 or more so unless i hid the sprite once it would bet below 0 the stretch command wouldn't work
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Feb 2008 20:58
Quote: "i checked out the stratch command and in the help bit it said that the stretch command couldn't have a value of 0 it had to always be 1 or more so unless i hid the sprite once it would bet below 0 the stretch command wouldn't work"

That would never be a problem as you don't need to display 0 health, your character would be dead

The way I'd do it is make 1% of your bar image and then stretch it out to the size you need, then you save file space

andycb
16
Years of Service
User Offline
Joined: 12th Jan 2008
Location:
Posted: 27th Feb 2008 21:18
Unfortunatly the bar isn't for the characters health. Its for a boost meter. In my game your a space ship and you have two speeds - normal and fast - but you can only go fast for a certain amount of time - as long as your boost bar lasts and this bar can get to 0.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Feb 2008 21:22
hmm... maybe 1% of the bar could be 0 on the meter or you could hide it.
I quite like the idea of 1% being 0, you could even have a little function that "turns on" the control panel and the bars appear and zoom up to maximum before settling back down. Like the way fighter jet control panels do

Login to post a reply

Server time is: 2024-09-27 12:21:29
Your offset time is: 2024-09-27 12:21:29