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.

AppGameKit Classic Chat / fade in intro screens

Author
Message
malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
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!
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
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.

malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
Posted: 28th Aug 2011 01: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.
malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
Posted: 28th Aug 2011 01: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
Steve O
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: The Netherlands
Posted: 28th Aug 2011 02:00
use the SetSpriteColorAlpha( iSpriteIndex, iAlpha ) command to only affect the alpha of your sprite.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 28th Aug 2011 03:34
Like Steve O said, but you've got to have a sync() in the loop there to make the changes show up.

malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
Posted: 28th Aug 2011 05:14
Thanks, I will try and report back!
malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
Posted: 28th Aug 2011 05: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 ?
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 28th Aug 2011 06: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.

Steve O
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: The Netherlands
Posted: 28th Aug 2011 17:29 Edited at: 28th Aug 2011 17:39
The range of the alpha parameter is from 0 to 255.

malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
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
Caps On!
12
Years of Service
User Offline
Joined: 3rd May 2011
Location:
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

Truth, Justice, and the Programmer's Way!
malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
Posted: 29th Aug 2011 06:22
Excellent thanks.

Login to post a reply

Server time is: 2024-03-28 09:19:08
Your offset time is: 2024-03-28 09:19:08