我試圖在Starling中設置assetManager。但我得到的運行時錯誤:AssetManager starling錯誤
Texture cannot be null at starling.display::Image()[C:\lars\starling\starling\src\starling\display\Image.as:70] at Game()[C:\lars\onkel_reje_air_3\src\Game.as:41] at starling.core::Starling/initializeRoot()[C:\lars\starling\starling\src\starling\core\Starling.as:338] at starling.core::Starling/initialize()[C:\lars\starling\starling\src\starling\core\Starling.as:314] at starling.core::Starling/onContextCreated()[C:\lars\starling\starling\src\starling\core\Starling.as:519]
我有以下EmbeddedAssets.as:
package
{
import starling.display.Image;
import starling.textures.Texture;
/**
* ...
* @author Lars Gregersen
*/
public class EmbeddedAssets
{
[Embed(source="assets/bord.jpg")]
public static const bord:Class;
}
}
在我game.as:
package
{
import starling.display.Sprite;
import starling.display.MovieClip;
import starling.display.Image;
import starling.events.Event;
import starling.text.TextField;
import starling.textures.Texture;
import starling.utils.AssetManager;
/**
* ...
* @author Lars Gregersen
*/
public class Game extends Sprite
{
public var assets:AssetManager = new AssetManager();
public function Game(){
assets.verbose = true;
assets.enqueue(EmbeddedAssets);
var backgroundImage:Image = new Image(assets.getTexture("bord"));
addChild(backgroundImage);
assets.loadQueue(function(ratio:Number):void{
trace("Loading assets, progress:", ratio);
if (ratio == 1.0)
});
}//end constructor
}//end class
}//end package
而且我Main.as:
package
{
//import flash.desktop.NativeApplication;
import flash.events.Event;
import flash.display.Sprite;
import starling.core.Starling;
/**
* ...
* @author Lars Gregersen
*/
public class Main extends Sprite
{
private var _starling:Starling;
public function Main():void
{
_starling = new Starling(Game, stage);
_starling.showStats = true;
_starling.start();
}
}
}
我有我的資產文件夾和.as fi在同一個文件夾(src)裏。使用Flashdevelop。它應該是簡單的,但...