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
MD5 algorithm
SaveScripts Xtra
Nero
StarMenu Xtra
Set FrameRate of a Animated Gif Cast Member
Cursor Trails
3D SpeedPort Xtra
DragNDrop Behaviour
3DPI
Puzzler - Puzzle Maker
 

 

 

Behavior Circular Rollover behavior

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: MichaelSeery

From providing a center point in the point[x1, y1] form and a radius in pixels, devise a behavior that will detect rollover of the the cursor in that region. No trig functions need to be used.

property radius
property origin
property originX
property originY
property boundingRect

on beginSprite
  set origin = point( originX, originY )
  set boundingRect = rect( originX - radius, originY - radius, originX + radius, originY + radius )
end

on exitFrame me
  set mouseLoc = point( the mouseH, the mouseV )
  if inside( mouseLoc, boundingRect ) then
    -- the mouse is in the ballpark
    set z = origin - mouseLoc
    set distance = sqrt ( the locH of z * the locH of z + the locV of z * the locV of z )
    if distance <= radius then
      -- it"s on the circle
      -- **DO YOUR THING HERE**
    else
      -- it"s close, but outside the circle
      nothing
    end if
    
  end if
end

on getBehaviorDescription
  return "Circular Rollover behavior, per Zav"s request."
end

on getPropertyDescriptionList
  set description = [:]
  addprop description, #radius, [ #default: 10.0, #format:#float, #comment:"radius:"]
  addprop description, #originX, [ #default: 100, #format:#integer, #comment:"x1:"]
  addprop description, #originY, [ #default: 100, #format:#integer, #comment:"y1:"]
  return description
end

 


Contact

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

Send e-mail