開車兜兜風… 
http://www.asn.com.tw/flex/cardrive/cardrive.html
http://www.asn.com.tw/flex/cardrive/cardrive2.html with BOX2D 
程式參考…
http://pv3d.org/2009/01/23/springcamera3d-and-driving-a-car/
重點在 driveCar() 及 updateCar() 兩個函式。
汽車控制幾乎都使用原作的,看別人的程式可以學到很多,沒想到原來不難,缺的大概就是經驗跟創意。
另一個重點是汽車的模型,在建模的時候就要先規畫好,要能配合程式運作,包括物件軸心、面向、四個輪子的軸心跟方向、子物件的名稱…。
圖檔及資源的讀取部份改寫如下…
使用一個陣列 push 所有需要讀取資源的 loader,並加入事件監聽,在收到完成的事件後再移出陣例,最後判斷是否己全數讀取完成,再進行其它的初始化工作。
        private var loadAssets:Array = new Array();
        private function initAssets():void
        {
            removeEventListener(Event.ADDED_TO_STAGE, initAssets);
            floorMaterial = new BitmapFileMaterial("assets/grassTexture.jpg");
            floorMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE,onLoadAssets);
            loadAssets.push(floorMaterial);
            bodyMaterial = new BitmapFileMaterial("assets/FocusBody.jpg");
            bodyMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE,onLoadAssets);
            loadAssets.push(bodyMaterial);
            wheelMaterial = new BitmapFileMaterial("assets/FocusWheel.jpg");
            wheelMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE,onLoadAssets);
            loadAssets.push(wheelMaterial);
        }
        
        private function onLoadAssets(e:FileLoadEvent):void
        {
            var idx:Number = loadAssets.indexOf(e.target);
            if( idx != -1 )
            {
                if( e.target is BitmapFileMaterial )
                    (e.target as BitmapFileMaterial).removeEventListener(FileLoadEvent.LOAD_COMPLETE,onLoadAssets);
                loadAssets.splice( idx, 1 );
                if( loadAssets.length == 0 )
                    initOther();
            }
        }
2009年11月21日 星期六
訂閱:
張貼留言 (Atom)
VirtualBox 空間減肥
@windows vm sdelete64 -z c: @macos VBoxManage modifymedium disk "/Users/fellow/VirtualBox VMs/Win10/Win10.vdi" --compact *.vdi...
- 
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...
- 
rails blog -d mysql 建立一個名為 blog 的網站app,使用 mysql cd blog 進去 gen 好的網站 config/database.yml 編輯資料庫設定 rake db:create 自動建立資料庫 ruby script/generate ...
 
沒有留言:
張貼留言