Hey everybody,
I searched the forum a couple of times for a solution but until now, I did not found the right answer to the issue i'm stuck with:
I want to display a sprite3D.
Fade that sprite3D to white
After a while fade back (from the white color) to the original colors of the Sprite.
Is something like this possible ?
I looked for drawing buffer, color palettes, I even thought of using DisplayAlphaSprite but the sprite has more than 256 colors.
All tips are welcome.
Regards,
DeXtr0
Sprite3D Color changing - Can't find it
Sprite3D Color changing - Can't find it
Proud member of dAWN (www.dawncreations.com)
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Fading to the background is easy enough using the transparency parameter of DisplaySprite3D(), but nothing comes to mind about fading to white. Here's a hack that might work for you if you don't find a better way of doing it (which probably does exist):
Code: Select all
InitSprite():InitSprite3D()
OpenWindow(0,0,0,320,240,"",$CA0001)
OpenWindowedScreen(WindowID(0),0,0,320,240,0,0,0)
CreateSprite(0,64,64,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(0))
Circle(32,32,32,#Red)
StopDrawing()
CreateSprite(1,64,64,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(1))
Circle(32,32,32,#White)
StopDrawing()
CreateSprite3D(0,0)
CreateSprite3D(1,1)
up=1:whitelevel=0
Repeat
If up
whitelevel+1:If whitelevel>254:up=0:EndIf
Else
whitelevel-1:If whitelevel<1:up=1:EndIf
EndIf
ev=WindowEvent()
ClearScreen(#Black)
Start3D()
DisplaySprite3D(1,20,20)
DisplaySprite3D(0,20,20,255-whitelevel)
Stop3D()
FlipBuffers()
Delay(1)
Until ev=#WM_CLOSE
BERESHEIT
Hey netmaestro,
You hack is quite good but not really what I was looking for.
The sprite is a full color png file and I want to fade that to white.
If you play with the transparancy parameter it just fades to the real color
However the idea was good and I hope to get some more tips.
Maybe others have already changed the colors of a sprite3D ?
Anyway thanks a lot for trying to help me out.
Appreciated,
DeXtr0
You hack is quite good but not really what I was looking for.
The sprite is a full color png file and I want to fade that to white.
If you play with the transparancy parameter it just fades to the real color

However the idea was good and I hope to get some more tips.
Maybe others have already changed the colors of a sprite3D ?
Anyway thanks a lot for trying to help me out.
Appreciated,
DeXtr0
Proud member of dAWN (www.dawncreations.com)
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
not a bad idea...
but if the base-sprite isn't filled squarish, that is also no solution.
when it has transparent areas itself, it won't work.
the only solution I can think of at the moment is to create the fading in multiple 2Dsprites,
and create several sprite3D out of them, to display the fading framewise.
this can be done on the fly for sure.
do you really need Sprite3D for it?
does it need to be an absolute independant rotateable and transformable picture?
if it's only for resizing, try to load it as image, resize it, and draw it on the sprite.
but if the base-sprite isn't filled squarish, that is also no solution.
when it has transparent areas itself, it won't work.
the only solution I can think of at the moment is to create the fading in multiple 2Dsprites,
and create several sprite3D out of them, to display the fading framewise.
this can be done on the fly for sure.
do you really need Sprite3D for it?
does it need to be an absolute independant rotateable and transformable picture?
if it's only for resizing, try to load it as image, resize it, and draw it on the sprite.
oh... and have a nice day.
perhaps a white solid sprite overlaid on a grab of the backgound (performed on the fly to allow for moving sprites) might workKaeru Gaman wrote:but if the base-sprite isn't filled squarish, that is also no solution.
when it has transparent areas itself, it won't work
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
Hey guys,
Well it does not "has" to be a sprite3D but it could be very handy.
Nevertheless that is not a "must".
I'm already very happy if it could work with a normal Sprite.
I think, the tip of citystate is a very good one.
I have not tought of that
I'll try it as soon as I got some time and I'll let you know if I solved it.
Thanks everybody for the great help.
Well it does not "has" to be a sprite3D but it could be very handy.
Nevertheless that is not a "must".
I'm already very happy if it could work with a normal Sprite.
I think, the tip of citystate is a very good one.
I have not tought of that

I'll try it as soon as I got some time and I'll let you know if I solved it.
Thanks everybody for the great help.
Proud member of dAWN (www.dawncreations.com)
citystate wrote:why not fade a white spite from transparent to opaque in front of your multi-coloured sprite?
Didn't netmaestro's snippet already do this? He drew a red circle sprite with a white circle sprite with transparency in front of it. All that is missing is a method of converting any sprite to a white sprite.DeXtr0 wrote:I think, the tip of citystate is a very good one.
I have not tought of that Smile
Actually you are 100% right.
netmaestro gave the same tip.
Sorry netmaestro.
Thanks demivec for mentionning it to me.
netmaestro gave the same tip.
Sorry netmaestro.
Thanks demivec for mentionning it to me.
Proud member of dAWN (www.dawncreations.com)