上次提到了 BitmapFileMaterial load 的時候使用一個 array,利用事件傳遞的方式來檢測什麼時候所有的圖片讀取完畢,好進行下一個有前後相依的步驟。
結果,今天 trace 了一下 BitmapFileMaterial 這個類別,發現原來它早就有把類似的機制作在裡面了,在BitmapFileMaterial.as 的這行…
static public var callback :Function;
於是,要讀取一連串的圖檔就變的更容易了…
public function init():void
{
BitmapFileMaterial.callback = loadComplete;
floorMaterial = new BitmapFileMaterial("assets/grassTexture.jpg");
bodyMaterial = new BitmapFileMaterial("assets/FocusBody.jpg");
wheelMaterial = new BitmapFileMaterial("assets/FocusWheel.jpg");
boxMaterial = new BitmapFileMaterial("assets/box.jpg");
}
private function loadComplete():void
{
BitmapFileMaterial.callback = null;
///......
}
雖然如此,但使用上也要特別小心,因為 BitmapFileMaterial.callback 是 public static 的,意即所有其它程序也是有可能在你讀取一堆圖檔的時候,使用同樣的方式設定了 callback 的函式,那就會出錯嘍(潛藏的BUG)。
訂閱:
張貼留言 (Atom)
VirtualBox 空間減肥
sdelete64 -z c: VBoxManage modifymedium disk "/Users/fellow/VirtualBox VMs/Win10/Win10.vdi" --compact *.vdi 路徑可以在 VirtualBox 儲...
-
https://github.com/ljean/modbus-tk/ install pip… sudo apt-get install python-pip install... download modbus_tk-x.x.x.tar.gz tar zxvf...
-
set0 bit 位元設0 set1 bit 位元設1 tog bit 位元0/1切換 swapc bit 位元與c切換 =================== call addr 呼叫副程式 goto addr 跳躍到標籤 icall [index] 呼叫指標指到的副程式 ig...
-
DMX protocol… # 1:break + 1:start + 512:channel python: import serial class DMX512: def __init__(self, port): self.seria...
沒有留言:
張貼留言