這個是在國外網站看到的,稍微修改就貼過來了。 它主要就是重複利用計時器物件,以節省資源,另外也可以省去 set timer=null 這清空動作。 要使用這些函數,把CreateTimer換成NewTimer,DestroyTimer換成ReleaseTimer。 //========================================================================================== function NewTimer takes nothing returns timer if (udg_tsnum==0) then return CreateTimer() endif set udg_tsnum=udg_tsnum-1 return udg_tstimer[udg_tsnum] endfunction //========================================================================================== function ReleaseTimer takes timer t returns nothing call PauseTimer(t) if (udg_tsnum==8191) then debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!") //stack is full, the map already has much more troubles than the chance of bug call DestroyTimer(t) else set udg_tstimer[udg_tsnum]=t set udg_tsnum=udg_tsnum+1 endif endfunction //==========================================================================================複製代碼
使用道具 舉報
本版積分規則 發表回覆 回帖並轉播 回帖後跳轉到最後一頁
Archiver|手機版|小黑屋|WEO
GMT+8, 2026-7-29 08:16 PM , Processed in 0.036417 second(s), 18 queries .
Powered by Discuz! X5.0 Licensed
© 2001-2026 Discuz! Team.