Screen fading examples (iPad/iPhone)
Posted: Sun Feb 15, 2015 1:14 am
Here is an example of fading the screen in and out by capturing it as a sprite and using the powerful sprite routines. This method can be used as a way to show a splash screen or just for dramatic effect. Fades, Zooms, Spins.
- Dav
- Dav
Code: Select all
'Just some full screen fading examples.
'Fades screen in/out, zooms in/out, spins.
'Grabs screen as sprite and uses that.
'Coded by Dav
'enter graphics mode
graphics
shadow on
'hide screen refresh while we draw
refresh off
'turn screen to pale green
graphics clear 0,.3,0
'draw some random stuff for show
'(1000 times...)
for t= 1 to 1000
c=rnd(255)/255 'random color
draw color 0,c,0 'set color
draw font size rnd(56) 'ramdom font size
x=rnd(screen_width()) 'random x position
y=rnd(screen_height()) 'random y position
'draw random letter
draw text chr$(rnd(255)) at x,y
next t
draw color 1,1,1
draw font size "40"
draw text device_name$() at 200,200
draw text device_type$() at 200,250
'grab entire screen as a sprite
sw=screen_width() ! sh=screen_height()
sprite "s" scan 0,0,sw,sh
'move it out of viewing area first
sprite "s" at -2000,-2000
'safe to turn on now its out of sight
sprite "s" show
'clear screen
graphics clear 0,0,0
'now turn on screen
refresh on
'fade in, fullscreen
for t = 0 to 100
sprite "s" alpha t/100
sprite "s" at 0,0
pause .02
next t
'fade out, fullscreen
for t = 100 to 0 step -1
sprite "s" alpha t/100
sprite "s" at 0,0
pause .02
next t
'fade in and zoom in
x=100
for t = 0 to 100
sprite "s" alpha t/100
sprite "s" at x,x scale t/100
pause .02 ! x=x-1
next t
'fade out and zoom out
for t = 100 to 0 step -1
sprite "s" alpha t/100
sprite "s" at x,x scale t/100
pause .02 ! x=x+1
next t
'fade in and zoom in and spin
x=100
for t = 0 to 100
sprite "s" alpha t/100
sprite "s" at x,x scale t/100 angle x/15
pause .02 ! x=x-1
next t
'fade out and zoom out and spin
for t = 100 to 0 step -1
sprite "s" alpha t/100
sprite "s" at x,x scale t/100 angle x/15
pause .02 ! x=x+1
next t
'that's all folks
text
end