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
LEAP YEAR
An Unofficial Brief History of Director
Director 8.5 Shockwave Studio: The Complete Reference
Slider Puzzle by J.R.D.R.
Remove border behavior
cXtraPopup
Invaders
Control Buttons for DirectMedia Sprite
Generic behavior to change System Desktop Icons
007 Fonts
 

 

 

Behavior Distance Sensitive Button

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: BasMul

Make a distance sensitive button This button reacts to the mouse by checking if the mouse is in the neigbourhood Currently supports 4 states (wich should be enough) We use it always in our projects for a back to the main menu button If you can use it, good for you! have fun!

property State0Pic,State1Pic,State2Pic,State3Pic,¬
                     State1X1,State1Y1,State1X2,State1Y2,¬
                     State2X1,State2Y1,State2X2,State2Y2,¬
                     State3X1,State3Y1,State3X2,State3Y2

on exitframe me
  set mx = the mouseh
  set my = the mousev
  if inside(point(mx,my),rect(the state3x1 of me,the state3y1 of me,¬
                                     the state3x2 of me,the state3y2 of me)) then
    set the member of sprite the spritenum of me = the State3Pic of me
  else if inside(point(mx,my),rect(the state2x1 of me,the state2y1 of me,¬
                                     the state2x2 of me,the state2y2 of me)) then  
    set the member of sprite the spritenum of me = the State2Pic of me
  else if inside(point(mx,my),rect(the state1x1 of me,the state1y1 of me,¬
                                     the state1x2 of me,the state1y2 of me)) then  
    set the member of sprite the spritenum of me = the State1Pic of me  
  else
    set the member of sprite the spritenum of me = the State0Pic of me
  end if  
end

on getPropertyDescriptionList
  set p_list =¬
              [#State0Pic:[#comment:"Normal state picture:",#format: #member,#default: ""],¬
               #State1Pic:[#comment:"State1 picture:",#format: #member,#default: ""],¬
               #State1X1 :[#comment:"State1 left:",#format: #integer,#default: 0],¬
               #State1Y1 :[#comment:"State1 top:",#format: #integer,#default: 0],¬
               #State1X2 :[#comment:"State1 right:",#format: #integer,#default: 0],¬
               #State1Y2 :[#comment:"State1 bottom:",#format: #integer,#default: 0],¬
               #State2Pic:[#comment:"State2 picture:",#format: #member,#default: ""],¬
               #State2X1 :[#comment:"State2 left:",#format: #integer,#default: 0],¬
               #State2Y1 :[#comment:"State2 top:",#format: #integer,#default: 0],¬
               #State2X2 :[#comment:"State2 right:",#format: #integer,#default: 0],¬
               #State2Y2 :[#comment:"State2 bottom:",#format: #integer,#default: 0],¬
               #State3Pic:[#comment:"State3 picture:",#format: #member,#default: ""],¬
               #State3X1 :[#comment:"State3 left:",#format: #integer,#default: 0],¬
               #State3Y1 :[#comment:"State3 top:",#format: #integer,#default: 0],¬
               #State3X2 :[#comment:"State3 right:",#format: #integer,#default: 0],¬
               #State3Y2 :[#comment:"State3 bottom:",#format: #integer,#default: 0]]
  return p_list
end

on getBehaviorDescription me
  return¬
              "Make a distance sensitive button."&RETURN&RETURN&¬
              "This button changes its castmember if the mouse get"s closer to it."&RETURN&¬
              "For it to work the smallest rectangle must be state3 and th largest State1."¬
              &RETURN&¬
              "I"ve done no checking if the rectangles are valid, that"s up to you!"&RETURN&¬
              "Good Luck!"
end  

 


Contact

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

Send e-mail