Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Testing CPU speed
Director's Third Dimension : Fundamentals of 3D Programming in Director 8.5
Director 8 Workshop
Application Xtra
Set WarpMode of a QTVR Sprite
ini-script
Color Cycle-Alphamania
Buddy Tray
Giving a shadow for a sprite
Slide show
 

 

 

Behavior Sprite Blender - Distance

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: GerryOrkin

Sprite Blender

-- 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

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail