Skip to content

Instantly share code, notes, and snippets.

@tmskst
Last active August 29, 2015 14:02
Show Gist options
  • Save tmskst/19e22745459fc757fa81 to your computer and use it in GitHub Desktop.
Save tmskst/19e22745459fc757fa81 to your computer and use it in GitHub Desktop.
FlashCCが生成するスプライトシートのSubTexture.@nameをSymbolItem.nameに書き換える

例えばデータ形式をStarlingに設定したときの話。

C:\Program Files\Adobe\Adobe Flash CC\Common\Configuration\Sprite Sheet Plugins にある Starling.plugin.jsflframeExportメソッドを書き換える。

function frameExport(frame) {
	var frameId = frame.id;
	if (frame.symbol != null && frame.frameSource instanceof SymbolItem) {
		frameId = frame.frameSource.name;
		var frameNumber = ('0000' + frame.frameNumber).slice(-4);
		frameId = frameId + frameNumber;
	}

	var s = '\t<SubTexture name="' + frameId + '" ... ';
	// 以下省略
}

ライブラリ項目名(jsfl.Item.name)が重複してもスプライトシートのサブテクスチャ名はjsfl.Item.nameが出力される。

<?xml version="1.0" encoding="utf-8"?>
<TextureAtlas imagePath="sprite-sheet.png">
	<!-- Created with Adobe Flash Professional version 13.1.0.226 -->
	<!-- http://www.adobe.com/products/flash.html -->
	<SubTexture name="Bar0000" x="2" y="198" width="35" height="35" pivotX="-32" pivotY="-4"/>
	<SubTexture name="Bar0001" x="2" y="235" width="35" height="35"/>
	<SubTexture name="Bar0002" x="2" y="272" width="35" height="35"/>
	<SubTexture name="Foo/Bar0000" x="2" y="2" width="47" height="47"/>
	<SubTexture name="Foo/Bar0001" x="2" y="51" width="47" height="47"/>
	<SubTexture name="Foo/Bar0002" x="2" y="100" width="47" height="47"/>
	<SubTexture name="Foo/Bar0003" x="2" y="149" width="47" height="47"/>
</TextureAtlas>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment