至此舞台上精灵的大小、位置等属性已设置完成。下面将通过Lingo语句,控制计时器的使用。
(17) 在工作窗口单击工具栏中的Script按钮 ,弹出Script窗口。设置脚本类型为Movie,在其中输入以下全局变量,如图8-13所示。
global timerhour
global timerminute
global timersecond

图8-13 数值全局变量
(18) 在Script窗口,加入以下settime句柄的Lingo控制语句,如图8-14所示。
on settime
set total = the timer/60
set timerhour= total /3600
set total = total - timerhour*3600
set timerminute = total/60
set timersecond = total-timerminute*60
end

图8-14 settime句柄
(19) 在Script窗口,加入以下changesprite句柄的Lingo控制语句,如图8-15所示。
on changesprite
set h1=timerhour/10
set h2=(timerhour-h1*10)
set m1=timerminute/10
set m2=(timerminute-m1*10)
set s1=timersecond/10
set s2=(timersecond-s1*10)
if (the castnum of sprite 5 = 2) then
set the width of sprite 5=2
else
set the width of sprite 5 = 22
end if
if (the castnum of sprite 6 = 2) then
set the width of sprite 6=2
else
set the width of sprite 6 = 22
end if
set the member of sprite 1 to member(h1+1)
set the member of sprite 2 to member(h2+1)
set the member of sprite 3 to member(m1+1)
set the member of sprite 4 to member(m2+1)
set the member of sprite 5 to member(s1+1)
set the member of sprite 6 to member(s2+1)
updatestage
end

图8-15 changesprite句柄
(20) 在舞台窗口中右击文本Reset,在弹出的快捷菜单中选择Script命令,在弹出的窗口中输入以下Lingo控制语句,如图8-16所示。
on mouseUp me
starttimer
end

图8-16 精灵12的Lingo脚本
(21) 在Score窗口的Script通道中,双击第1帧。在弹出的窗口中,加入以下的Lingo控制语句,如图8-17所示。
on exitFrame me
go to the frame
end
on idle
settime
changesprite
end

图8-17 第1帧Lingo脚本
(22) 至此,计时器动画的制作完成了。播放效果如图8-18所示。

图8-18 计时器播放效果
|