Posted: 27th Aug 2011 23:06
Sorry if this is a dumb question, I'm a newbie starting just today. I'm trying to go through as much documentation, and searching etc. I was wondering if I could get help with the following:

I have multiple full images that I want to show, and starting with the first image I want it to stay for a couple of seconds, then FADE and then go to the next image. I can't find how to fade backgrounds. If anybody could help that would be awesome. Thanks ahead of time!
Posted: 27th Aug 2011 23:59
If your image is a srite (and it really has to be) then you can just loop the sprite's alpha level from 255 to zero, change the sprite image, and then loop it back from 0 to 255. Fade to black, switch, fade from black.

Or, with two full-screen sprites, you can fade one away while you fade the other in, for a cross-dissolve.
Posted: 28th Aug 2011 1:08
I figured it would be something like that but the problem is I wanted to do something like that but for example using the function SetSpriteColor( iSpriteIndex, iRed, iGreen, iBlue, iAlpha ), I know I can change the iAlpha with a loop, but what do I do with iRed, iGreen, and iBlue in order to keep them the same, as I could not find a function that would retrieve those values.
Posted: 28th Aug 2011 1:49
I tried that but the screen just stays white with this code:


backdrop=CreateSprite( LoadImage("afterlightlogo.png"))

timei=getseconds()

for fade = 255 to 0
SetSpriteColor (backdrop, fade, fade, fade, fade)
next fade
_fakestart:
if ( (getseconds()-timei)<4.0)
goto _fakestart
endif

I also tried keeping the first three fade values at 255 but that did not work either
Posted: 28th Aug 2011 2:00
use the SetSpriteColorAlpha( iSpriteIndex, iAlpha ) command to only affect the alpha of your sprite.
Posted: 28th Aug 2011 3:34
Like Steve O said, but you've got to have a sync() in the loop there to make the changes show up.
Posted: 28th Aug 2011 5:14
Thanks, I will try and report back!
Posted: 28th Aug 2011 5:19
In the documentation for SetSpriteColorAlpha its incomplete as to what values iAlpha takes, it states "iAlpha - The alpha component of the color. The acceptable range is from 0" . from 0 to ?
Posted: 28th Aug 2011 6:01
If you want to change the colour of a sprite and revert it back to the original, just save the original colours first. Just use the getspritecolourred, green and blue ommands and save them to an array or variables for later retrival.
Posted: 28th Aug 2011 17:29
The range of the alpha parameter is from 0 to 255.
Posted: 28th Aug 2011 18:22
Thanks guys this code works awesome:

timea=getseconds()

ii=0
//wait 6 seconds before proceeding
while ( (getseconds()-timea)<6 )
SetSpriteColorAlpha(backdrop,ii)
ii=ii+1

sync()
endwhile
Posted: 28th Aug 2011 20:27
Here are some functions that might be useful to some....

rem *****Fade_in***** syntax: fade_in(1,10)
rem "This will fade sprite #1 in from 1 to 255 in steps of 10. Speed must be a number between 1 and 255."
function fade_in(imageid,speed)
alpha = 0
do
alpha = alpha + speed
setspritecoloralpha(imageid, alpha)
sync()
if alpha > 255 then alpha=255
if alpha = 255 then exit
loop
endfunction

rem *****Fade_Out***** syntax: fade_out(1,10)
rem "This will fade sprite #1 out from 255 to 1 in steps of 10. Speed must be a number between 1 and 255."
function fade_out(imageid,speed)
alpha = 255
do
alpha = alpha - speed
SetSpriteColorAlpha(imageid,alpha)
sync()
if alpha < 1 then exit
loop
endfunction

rem *****Pause***** syntax: pause(time#)
rem "This function pauses a program for a given length of time. For example, pause(3.5) will pause for 3.5 seconds"

function pause(time#)
StartTime# = timer()
do
if timer() - StartTime# => time# then exit
sync()
loop
endfunction
Posted: 29th Aug 2011 6:22
Excellent thanks.