アナログ時計

アナログ時計(2420bytes)

アナログ時計です。
DirectorではLINE命令というのが存在しませんが、工夫次第で同様の効果を出すことができます。
その工夫というのは、the rect of sprite to rect(左、上、右、下)を利用することです。これを利用することで、単なるシェイプキャストの直線が、様々な効果を出すことができるのです。
上の図で示しているように、傾きを変えるようなときには、
  set the rect of sprite 1 to rect(160,160,250,240)
  set the rect of sprite 1 to rect(160,200,320,240)
と記述します。
今回は時間を管理するので、ちょっとした工夫が必要ですが、cosとかsinとかの知識があれば、大丈夫だと思います(たぶん)。
今回はかなり泥臭い方法で書いていますが、工夫すればもっと簡単に記述できます。なお、短針の記述スクリプトだけ掲載し、長針・秒針は省きました。
短針の方でスプライトを使い分けているのは、右上がりの直線左上がりの直線を使い分けているからです。
radとはラジアンのことで、2π=1radです(数学でやりましたよね、たぶん....)

on timeManage
 global hour,minute,second
 --
 put the long time into nowTime
 if chars (nowtime,2,2) = ":" then
  put chars(nowtime,1,1) into Hour
  put chars(nowtime,3,4) into minute
  put chars(nowtime,6,7) into second
 else
  put chars(nowtime,1,2)into Hour
  put chars(nowtime,4,5) into minute
  put chars(nowtime,7,8) into second
 end if
end

on hourDraw
 global hour,minute
 --
 if hour>=13 then set hour=hour-12
 if hour=12 or hour=24 then set hour=0
--  set hourMin to hour*5+minute/12.0
 set hourRad = abs(pi()*(0.50-(hour*5+minute/12)/30.0))
 --
 if hourMin = 0 or hourMin=60 then
  puppetsprite 6,false
  puppetsprite 5,true
  set x=rect(157,100,163,160)
  set the rect of sprite 5 to x
 else if hourMin>0 and hourMin <15 then
  set x= rect (160, 160-60*sin(hourRad), 160+60*cos(hourRad), 160)
  set the rect of sprite 5 to x
 else if hourMin =15 then
  set x=rect(160,157,220,163)
  set the rect of sprite 5 to x
 else if hourMin>15 and hourMin <30 then
  puppetsprite 5,false
  puppetsprite 6,true
  set x= rect(160,160,160+60*cos(hourRad),160+60*sin(hourRad))
  set the rect of sprite 6 to x
 else if hourMin =30 then
  puppetsprite 6,false
  puppetsprite 5,true
  set x=rect(157,160,163,220)
  set the rect of sprite 5 to x
 else if hourMin >30 and hourMin <45 then
  set x=rect(160+60*cos(hourRad),160,160,160+60*sin(hourRad))
  set the rect of sprite 5 to X
 else if hourMin=45 then
  puppetsprite 5,false
  puppetsprite 6,true
  set x=rect (100,157,160,163)
  set the rect of sprite 6 to x
 else if hourMin>45 and hourMin <60 then
  set x=rect(160+60*cos(hourRad),160+60*sin(hourRad),160,160)
  set the rect of sprite 6 to X
 end if
end


© Akira SAno 1996
一応こんなページでも著作権は佐野彰に存在します
リンクフリーですがメールでご連絡頂けたら嬉しいです

96/11/6更新 homeホームに戻る