LoginSignup
0
0

More than 5 years have passed since last update.

テクスチャアトラス画像を入れ子にする

Last updated at Posted at 2016-05-04

こちらの記事と同じようなやつなんですが、
ビットマップフォント画像を他とまとめて1ドローコールを目指す

Starling(2.0で確認したがたぶん1.xも)では、アトラス画像(スプライトシート画像)の中にアトラス画像を入れ子で突っ込んでもうまく動作するのですね。

sample.as
// アトラス画像(colorbars.pngを含む)
_assetManager.enqueueWithName('app:/assets/atlas.png');
// 全体アトラス設定
_assetManager.enqueueWithName('app:/assets/atlas.xml');
 // 入れ子にされてるアトラス画像の設定
_assetManager.enqueueWithName('app:/assets/colorbars.xml');
_assetManager.loadQueue(function(ratio:Number):void {
    if(ratio == 1) {
    // do something..
    }
});

atlas.png
atlas画像:atlas.png(colorbars.pngを含んでいる)


atlas画像:colorbars.png

atlas.xml
<TextureAtlas imagePath="atlas.png" width="228" height="151">
    <SubTexture name="alphabet" x="151" y="1" width="76" height="78"/>
    <SubTexture name="colorbars" x="151" y="81" width="7" height="31" frameX="0" frameY="0" frameWidth="8" frameHeight="32"/>
    <SubTexture name="kana_only" x="1" y="1" width="148" height="149"/>
</TextureAtlas>
colorbars.xml
<TextureAtlas name="colorbars" imagePath="colorbars.png">
  <!-- 一部の抜粋 -->
  <SubTexture name="color6" x="4" y="12" width="2" height="2"/>
  <SubTexture name="color5" x="0" y="16" width="2" height="2"/>
  <SubTexture name="color4" x="4" y="4" width="2" height="2"/>
  <SubTexture name="color3" x="4" y="8" width="2" height="2"/>
  <SubTexture name="color2" x="4" y="20" width="2" height="2"/>
  <SubTexture name="color1" x="4" y="28" width="2" height="2"/>
  <SubTexture name="color0" x="4" y="16" width="2" height="2"/>
</TextureAtlas>

これで、ばっちりcolorbars内のテクスチャが参照できます。

sample.as
var texture:Texture = _assetManager.getTexture("color1");

別作業中に気づきました。パックをパックできるので、便利かもしれない。ドローコールもまとまる。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0