在遊戲開發過程中,對圖片的載入需要消耗記憶體,以前我們只能一張一張的載入,這樣會耗費很大的記憶體,而記憶體對於手機來說是非常寶貴得。Android手機給每個應用程式分配了一定的記憶體,超過記憶體就會被回收掉。所以我們得想個辦法來實現節省記憶體。

 

下面我介紹一下我做遊戲使用的圖片打包工具吧。TexturePacker----它幾乎可以支援所有2d遊戲引擎以及部分3d遊戲引擎。

 

1.我們打開軟體->
20140411190154236  
2.擇需要打包的格式->
3.添加圖片->
 
20140411190156239  
4.調整參數->
5.發佈(publish)
20140411190156240  
6.在libgdx中使用
mAssetManager = new AssetManager();
mAssetManager.load(Assert.MENUUI, TextureAtlas.class);
mAssetManager.load(Assert.SOUND1, Sound.class);
mAssetManager.load(Assert.SOUND2, Sound.class);
mAssetManager.load(Assert.SOUND3, Sound.class);
mAssetManager.load(Assert.DROP, Sound.class);
mAssetManager.finishLoading();

 

mAtlas = mAssetManager.get(Assert.MENUUI, TextureAtlas.class);

 

使用的時候:
mControlRegion = mAtlas.findRegion("control_level");

 

注意在libgdx中打包進去的圖片是不用輸入圖片尾碼名的!!!
7.軟體位址:
HTTP://www.codeandweb.com/texturepacker
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()