|
|
|
Circular Rollover behavior
Added on 6/10/1999
|
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
|
|