|
|
Mark's Taskbar v2
Added on 6/10/1999
|
Taskbar Behavior
property backSprite, speed, buttonString, direction, holdOnMouseDown, mouseDetect, mouseTest
property onStageTest, offStageTest, barBox, onStage, inLoc, rollSpeed, buttonList
on getBehaviorDescription
return "Taskbar behaviour, by Mark Hagers." & return & "© 1997 Mediaeval Multimedia" & return & "email: mark@mediaeval.nl" & return & "Behaviour for a Win95 style taskbar sprite that will roll on/off stage depending on the mouse position." & return & "The initial position of the taskbar (during authoring) will be the 'on stage' position for the taskbar when the movie runs." & return & "To disable the taskbar in some frames, just remove it from the score in those frames (including it's gadget sprites)." & return & "The parameters for this behaviour:" & return & " - Roll on/off speed: controls the speed of movement on and off stage." & return & " Setting this to zero will result in the taskbar (dis)appearing instantly." & return & " - Roll off direction: which direction the taskbar rolls off stage, usually, but not necessarily," & return & " the edge of the stage where the taskbar sits." & return & " - Gadget List: which sprites" && quote & "belong" & quote && "to the taskBar, they roll on and off together with it." & return & " Just enter the appropriate sprite numbers separated by commas i.e.: 21,22,23,24,etc." & return & " - Mouse detection: Choose 'area' to let the bar roll on stage only when the mouse is within it's on-screen area," & return & " choose 'border' to detect when the mouse is past the border of the bar closest to the center of the screen." & return & " - Fixed while mousedown: check this to prevent the bar from rolling off stage while the mouse is down."
end getBehaviorDescription
on getPropertyDescriptionList
if the currentspritenum = 0 then
set butdefault = []
set speeddefault = 0
else
set butdefault = string(the currentSpriteNum + 1)
set speeddefault = 10
end if
set description = [:]
addProp description, #speed, ¬
[#default:speeddefault,#format:#integer,#comment:"Roll-on/off speed:",#range:[#min:0,#max:100]]
addProp description, #direction, ¬
[#default:#bottom,#format:#symbol,#comment:"Roll off direction:",#range:[#bottom,#left,#top,#right]]
addprop description, #buttonString, ¬
[#default:butdefault,#format:#string,#comment:"Gadget sprites:"]
addprop description, #MouseDetect, ¬
[#default:#Border,#format:#symbol,#comment:"Mouse detection:",#range:[#border,#area]]
addprop description, #holdOnMouseDown, ¬
[#default:true,#format:#boolean,#comment:"Fixed while mousedown:"]
return description
end getPropertyDescriptionList
--------
on beginSprite me
set buttonList = stringToList(buttonString)
set the backSprite of me = the spriteNum of me
set the barBox of me = the rect of sprite backSprite
put the backSprite of me + 1 into firstBut
set the inLoc of me = the loc of sprite the backSprite of me
initDir me
return me
end
on initDir me
put the frameTempo into tempo
put the stageBottom - the stageTop into stageHeight
put the stageRight - the stageLeft into stageWidth
case (the direction of me) of
#bottom:
put "the locV of sprite" && backSprite && ">" && the locV of inLoc into onStageTest
put "the top of sprite" && backSprite && "<" && stageHeight into offStageTest
if speed = 0 then
put (the stageBottom - the top of sprite backSprite) into roll
else put speed into roll
put point(0,roll) into rollSpeed
set mouseTest = "the mouseV >" && the top of sprite backSprite
#left:
put "the locH of sprite" && backSprite && "<" && the locH of inLoc into onStageTest
put "the right of sprite" && backSprite && ">" && 0 into offStageTest
if speed = 0 then
put the right of sprite backSprite into roll
else put speed into roll
put point(- roll,0) into rollSpeed
set mouseTest = "the mouseH <" && the right of sprite backSprite
#top:
put "the locV of sprite" && backSprite && "<" && the locV of inLoc into onStageTest
put "the bottom of sprite" && backSprite && ">" && 0 into offStageTest
if speed = 0 then
put the bottom of sprite backSprite into roll
else put speed into roll
put point(0,- roll) into rollSpeed
set mouseTest = "the mouseV <" && the bottom of sprite backSprite
#right:
put "the locH of sprite" && backSprite && ">" && the locH of inLoc into onStageTest
put "the left of sprite" && backSprite && "<" && stageWidth into offStageTest
if speed = 0 then
put (the stageRight - the left of sprite backSprite) into roll
else put speed into roll
put point(roll,0) into rollSpeed
set mouseTest = "the mouseH >" && the left of sprite backSprite
end case
if mouseDetect = #area then set mouseTest = "inside(point(the mouseH, the mouseV), barBox)"
end
on prepareframe me
if value(mouseTest) then
moveIn me
else moveOut me
end
on moveOut me
if holdOnMouseDown and the mouseDown then
-- hold buttonbar onstage
else
if value(offStageTest) then
set the loc of sprite backSprite to rollSpeed + the loc of sprite backSprite
repeat with i in buttonlist
set the loc of sprite i to rollSpeed + the loc of sprite i
end repeat
end if
end if
end
on moveIn me
set onStage = value(onStageTest)
if onStage then
set the loc of sprite backSprite to - rollSpeed + the loc of sprite backSprite
repeat with i in buttonlist
set the loc of sprite i to - rollSpeed + the loc of sprite i
end repeat
end if
end
on stringToList spritestring
set newList = []
do "set newList = [" & spritestring & "]"
return newList
end
|
|