![]() sweeper code snippet | show it | return | |
on startmovie
global gRadToAng
-- constant for converting angles to radians
put pi()/180 into gRadToAng
end
on sweeper circleSprite, lineSprite
global gRadToAng
-- NOTE:
-- Much of this parameter setting should be done in
-- in an earlier handler (i.e. a set-up frame) and
-- set to global variables.
-- get origin
put the locH of sprite circleSprite into originalLoc
put the locH of sprite circleSprite + ¬
integer(the width of sprite circleSprite / 2) into h1
put the locV of sprite circleSprite + ¬
integer(the height of sprite circleSprite / 2) into v1
put 1 + integer(the width of sprite circleSprite / 2) into radius
-- get cast numbers for the two lines used
put the number of cast "line 1" into lineCast1
put the number of cast "line 2" into lineCast2
-- match the color of the line that sweeps to the stage
set the forecolor of sprite lineSprite to the stageColor
-- quadrant 1
repeat with theta=360 down to 271
set the castNum of sprite lineSprite to lineCast1
spriteBox lineSprite, h1, v1, h1 + ¬
integer( radius * cos( theta * gRadToAng ) ), ¬
v1 + integer( radius * sin( theta * gRadToAng ) )
updateStage
end repeat
-- quadrant 2
repeat with theta=270 down to 181
set the castNum of sprite lineSprite to lineCast2
spriteBox lineSprite, h1, v1, h1 ¬
+ integer( radius * cos( theta * gRadToAng ) ), ¬
v1 + integer( radius * sin( theta * gRadToAng ) )
updateStage
end repeat
-- quadrant 3
repeat with theta=180 down to 91
set the castNum of sprite lineSprite to lineCast1
spriteBox lineSprite, h1, v1, h1 + ¬
integer( radius * cos( theta * gRadToAng ) ), ¬
v1 + integer( radius * sin( theta * gRadToAng ) )
updateStage
end repeat
-- quadrant 4
repeat with theta=90 down to 1
set the castNum of sprite lineSprite to lineCast2
spriteBox lineSprite, h1, v1, h1 + ¬
integer( radius * cos( theta * gRadToAng ) ), ¬
v1 + integer( radius * sin(theta * gRadToAng ) )
updateStage
end repeat
-- stamp the cicrle with trails on to reset
set the locH of sprite circleSprite to -1000
updateStage
set the locH of sprite circleSprite to originalLoc
updateStage
end sweeper
|
| Requires paramters of a quickdraw circle (the background) and 2 line cast members, (one for nw/se orientations, one for ne/sw orientations), and a solid stage background. The line is used with trails to "sweep" out the arc of a circle, and effectively erasing the background circle.
lingo era = v4.0 - 5.0 The function spriteBox is old Lingo and should be done now dy directly setting sprite.rect = rect(x1,y1, x2,y2). This could easily now be done as a behavior, or better yet, with vector cast members. Or best, in Flash! |