-- gerry orkin
--gorkin@coombs.anu.edu.au
--if you use this let me know and acknowledge in your credits
--if you improve it, send me a copy :)
-- initial blend for the sprite
property startBlend
-- how far away should the fade begin?
property StartFadePoint
-- how far away should the fade stop
-- (at which point the blend should = 100) ?
property EndFadePoint
on beginSprite me -- sets initial blend
puppetsprite the spriteNum of me, 1
set the blend of sprite the spriteNum of me = startBlend
updatestage
end
on exitFrame me -- provides the trigger for the blend updates
sendSprite (the spritenum of me, #blendit)
end
on blendSprite which, what -- does the blending :)
set the blend of sprite which = what
updatestage
end
on blendit me
set dv = abs((the locV of sprite the spriteNum of me) - the mousev)
set dH = abs((the locH of sprite the spriteNum of me) - the mouseh)
set distance = sqrt( dV * dV + dH * dH )
if distance < EndFadePoint then
blendSprite the spriteNum of me,100
exit
end if
if distance < StartFadePoint then
set percentage = (distance*100/StartFadePoint)
set blendToValue = (100-percentage)
if blendToValue < startBlend then set blendToValue = startBlend
blendSprite the spriteNum of me,blendToValue
else
blendSprite the spriteNum of me,startBlend
end if
updatestage
end
on getPropertyDescriptionList
set p_list = [¬
#startBlend: [ #default:0, #format:#integer, #comment:"Initial Blend",#range: [#min:0,#Max:100]] ,¬
#StartFadePoint: [ #default:100, #format:#integer, #comment:"Trigger Point", #range:[#min:0,#Max:500]],¬
#EndFadePoint: [ #default:0, #format:#integer, #comment:"End Trigger Point", #range:[#min:0,#Max:50]] ¬
]
return p_list
end
on getBehaviorDescription
return "Creates sprites that fade in and out (using the sprite blend property) depending how far they are from the mouse. " &return&return&¬
"Try different inks for your sprites - different images require different settings. Also, there appears to be a bug in Director 6 that prevents sprites with a blend of 0 from being totally hidden. "
end
|