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