Fade in / fade out?
Blitz3D Forums/Blitz3D Programming/Fade in / fade out?
| ||
Hello all! :) As you may well already know, I've been working on my 2/1/2-D Ball Physics game. I've run into a snag and can't quite figure out what is going on here with this small code. Why can't I get this to gradually fade in an object's alpha by x amount of fade level? (IE: If the "alpha#" value in the function parameters = 0.01, then it would increment by 0.01 every time until it reached 1.0 alpha). I'm basically trying to fade in or out, a single 3D object NOT attached to the camera. What am I doing wrong here and how can I correct it? Thank You kindly all, & have a nnice day! =) ~GF |
| ||
*cough* where is a# declared? *cough* Use IDEal and work with Strict mode enabled to catch errors like this early (it will highlight them in red in the edit view). |
| ||
*cough* even when a# WAS declared a local, it still didn't work -.- |
| ||
*cough* *cough* folks. a# ist local, so if you call the function it is always 0 and you don't return the a# value back. Solution: make a# global or rewrite your code to return the local a# value somehow and give it back to the function if you call it the next time. |
| ||
RenderWord on function |
| ||
;Remember when you CALL this function, you need some way to STORE the CURRENT Alpha which is now returned. By Default, there is no GetEntityAlpha() comand.You don't need pos / neg - just a 'direction' flag for +1, -1 or 0. [code] Function Fade_Obj(ent, dir=0, CurrentAlpha#=1.0) Local Alpha#=CurrentAlpha#+(Sgn(dir)*0.1) If ((Alpha<0.0)Or (Alpha>1)) Alpha=Alpha-(Sgn(dir)) End If DebugLog "Alpha: "+Alpha# EntityAlpha(Ent, Alpha#) Return Alpha# End Function |