開車兜兜風…
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();
}
}
訂閱:
張貼留言 (Atom)
更高效處理 micro second 的方式
更高效處理 micro second 的方式… 以 STM32 為例… __IO unsigned long sys_tick = 0; void SysTick_Handler(void) { HAL_IncTick(); sys_tick += (SysTi...
-
rails blog -d mysql 建立一個名為 blog 的網站app,使用 mysql cd blog 進去 gen 好的網站 config/database.yml 編輯資料庫設定 rake db:create 自動建立資料庫 ruby script/generate ...
-
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...
-
DMX protocol… # 1:break + 1:start + 512:channel python: import serial class DMX512: def __init__(self, port): self.seria...
沒有留言:
張貼留言