Director綜合技巧:director 運用靈活技術
2024-09-08 19:26:57
供稿:網友
director 應用技巧
1、設置movie,使之自動縮放以適應屏幕大小
a:使用如下script:
on preparemovie
(the stage).rect=(the desktoprectlist).[1]
(the stage).drawrect=(the desktoprectlist).[1]
end
2、制作帶陰影效果的text
field可以作出陰影效果,但在field中應用中文容易死機,我們可以用一個text member但多個sprite,各sprite位置稍稍錯開,并適當設置其blend即可。靈活使用之可以得到動態的和彩色的陰影。缺點是數量過多會拖累速度。
3、中文菜單
可以用installmenu的標準方法生成中文菜單,但字體、字號設置全部無效。
4、filmloop播放問題:在一幀內判斷一個filmloop播放完畢,再繼續播放下一幀。
frame script中含有以下代碼,以實現‘‘定格/‘‘:
on exitframe me
go the frame
end
再把以下behavior拖到filmloop sprite即可:
on exitframe me
--但用prepareframe不行?!
tell sprite(me.spritenum)
if the frame = the lastframe then
ploopcnt = 1
end if
end tell
if ploopcnt then
go next --或改為其它命令
end if
end
5、對filmloop的控制。
以下behavior的功能是用于一個filmloop sprite,點擊暫停,再次點擊則繼續。
property ppause,pframe
on beginsprite me
ppause=false
pframe=1
end
on mouseup me
ppause=not ppause
if ppause then
tell sprite(me.spritenum) to pframe=the frame
end if
end
on exitframe me
if ppause then
if pframe=1 then
tell sprite(me.spritenum) to go to the lastframe
else
tell sprite(me.spritenum) to go to pframe-1
end if
end if
end
由此我們也可以知道,我們無法使filmloop的播放速度快于movie,但可以用上法的變通來減慢它。
補充說明:tell sprite...用法類似tell window,但尚未見于正式文檔,我使用至今,尚未見其出錯。
6、在projector用lingo關閉計算機(用于windows9x),主要用于觸摸屏等無人值守的情況等。
a:無論此時計算機是否有打開的程序或窗口,使用下面的lingo語句可直接關機:(僅限于projector)
open ‘‘c:/windows/rundll.exe user.exe,exitwindows‘‘
若要重新啟動計算機,改為 ‘‘c:/windows/rundll.exe user.exe ,exitwindowsexec‘‘
當然在實際的projector中不能直接用‘‘c:/windows‘‘,而要用fileio的getosdirectory()等函數先獲得系統相應目錄。
7、在runtime動態地改為director內置的圖標
最常用和簡單的方法是對于一個sprite,施與以下behavior:
on beginsprite me
sprite(me.spritenum).cursor=280 --手形光標
end
一般的光標設置以上一句就夠了,更具個性化的光標設置這里不談了。
內置圖標(有些是相同的):0-4 200 254 256-269 271-272 280-281 284-286 290-304
8、lingo支持遞歸!
用到搜索算法的朋友們應該高興吧。
9、director中事件發生的順序
preparemovie
beginsprite for frame 1
stepframe for frame 1
prepareframe for frame 1
startmovie
enterframe for frmae 1
exitfrmae for frame 1
beginsprite for next frame
10、設置搜索路徑的合適位置
a:實際上,在preparemovie前,所用到的cast及相關的member包括其鏈接關系都應作好準備。
所以不可在movie內為自身設置搜索路徑。一般在stub player中設置searchpath為佳。