Load Multiple .awd format models in my game

Software: Away3D 4.x

incubus, Newbie
Posted: 29 December 2013 03:44 PM   Total Posts: 21

Hello, I’m just create a like temple run game. But I can’t realize how can I load models and don’t know which way is correct for this. I’ve lots of models converted with .awd format. But still don’t know how can I setup all models and position objects correcly.

sorry for english isn’t my mother tongue. smile and thank you so much!

Here is my simple approach something like this

Main class:

var models:LoadModels = new LoadModels();
models.loadModel("player.awd");
models.loadModel("banana.awd");
models.loadModel("coin.awd");
models.loadModel("mountains.awd");
models.loadModel("ground.awd"); 


LoadModels class :

private var modelDictionary:Dictionary;
    private var 
loader:Loader3D;

     public function 
LoadModels() 
     
{
         modelDictionary 
= new Dictionary();
     
}

     
public function loadModel(path:String):void
     {
         Parsers
.enableAllBundled();
         
loader = new Loader3D();
         
loader.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
         
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
         
loader.load(new URLRequest("models/"+path));
     
}

    
private function onResourceComplete(event:LoaderEvent):void
    {
                 trace
("loaded resource");
    
}

    
private function onAssetComplete(event:AssetEvent):void
    {
            trace
("loaded assets");
    
   

incubus, Newbie
Posted: 30 December 2013 12:41 PM   Total Posts: 21   [ # 1 ]

I figure out how done this. Maybe someone needs this.

AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
AssetLibrary.load(new URLRequest("../models/banana.awd"));
AssetLibrary.load(new URLRequest("../models/cows.awd")); 

onAssetComplete method :

trace("loaded. type : " event.asset.assetType );
        
trace("asset name : " event.asset.name);
        if(
event.asset.assetType == AssetType.MESH)
        
{
            
var m:Mesh event.asset as Mesh;
            
m.scale(20);
            
scene.addChild(m);

            if(
event.asset.name == "cow")
            
{
                trace
("write someting..");
                
cow_mesh event.asset as Mesh;
                

            
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X