• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            戰(zhàn)魂小筑

            討論群:309800774 知乎關(guān)注:http://zhihu.com/people/sunicdavy 開源項(xiàng)目:https://github.com/davyxu

               :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              257 隨筆 :: 0 文章 :: 506 評(píng)論 :: 0 Trackbacks

            cocos2dx引擎使用plist文件, 一種特殊的xml格式作為其atlas紋理的描述文件. plist遵循蘋果的xml中key-value的設(shè)計(jì)風(fēng)格.對(duì)于OC來說是合適的, 但xml本身性能低下, 垃圾內(nèi)容過多, 也讓plist對(duì)于高性能游戲引擎不再適合. 因此, 研究TexturePacker的導(dǎo)出插件技術(shù)

            TexturePacker的自定義插件目錄位于其安裝目錄的bin\exporters\下, 但有一些插件屬于內(nèi)建支持, 例如cocos2dx的plist格式, 因此無法找到對(duì)應(yīng)插件

            本人參考shiva3d插件, 對(duì)應(yīng)導(dǎo)出界面的DataFormat中的Shiva3D, 快速學(xué)會(huì)了如何導(dǎo)出

            官方文檔位于http://www.codeandweb.com/texturepacker/documentation/#customization

            插件的基本格式及原理是:

            bin\exporters\下的某一目錄下存在的一個(gè)名為exporter.xml文件作為插件的描述,例如:

            <exporter version="1.0">
                <!-- identifier of the exporter -->
                <name>shiva3d</name>
             
                <!-- display name of the exporter for the combo box -->
                <displayName>Shiva3D</displayName>
                
                <!-- description of the exporter -->
                <description>Exporter for Shiva3D.</description>
             
                <!-- exporter version -->
                <version>1.0</version>
                
                <!-- currently only one file allowed - more to come with update -->
                <files>
                    <file>
                        <!-- name of this file variable -->
                        <name>xml</name>
             
                        <!-- human readable name (for GUI) -->
                        <displayName>XML</displayName>
             
                        <!-- file extension for the file -->
                        <fileExtension>xml</fileExtension>
             
                        <!-- name of the template file -->
                        <template>shiva.xml</template>
                    </file>
                </files>
             
                <!-- target framework supports trimming -->
                <supportsTrimming>false</supportsTrimming>
             
                <!-- target framework supports rotated sprites -->
                <supportsRotation>true</supportsRotation>
             
                <!-- rotated sprites direction (cw/ccw) -->
                <rotationDirection>cw</rotationDirection>
             
                <!-- supports npot sizes -->
                <supportsNPOT>true</supportsNPOT>
             
                <!-- supports file name stripping (remove .png etc) -->
                <supportsTrimSpriteNames>yes</supportsTrimSpriteNames>
             
                <!-- supports texure subpath -->
                <supportsTextureSubPath>yes</supportsTextureSubPath>
             
            </exporter>
             
             

             

            在Template字段中, 描述同目錄的導(dǎo)出文件格式模板. TexturePacker使用一種叫Grantlee的模板引擎,類似于Python使用的Django模板引擎, 文檔參見:Grantlee Documentation. 簡單的文本格式可以參考shiva.xml快速學(xué)會(huì)

            這里我們使用protobuf的文本格式(極為類似json)導(dǎo)出plist, 下面是導(dǎo)出模板

             

            {% for sprite in allSprites %}
            Sprite {
                Name: "{{sprite.trimmedName}}"
                FrameX: {{sprite.frameRect.x}}
                FrameY: {{sprite.frameRect.y}}
                FrameWidth: {{sprite.frameRectWithoutRotation.width}}
                FrameHeight: {{sprite.frameRectWithoutRotation.height}}
                OffsetX: {{sprite.cornerOffset.x}}
                OffsetY: {{sprite.cornerOffset.y}}
                OriginalWidth: {{sprite.untrimmedSize.width}}
                OriginalHeight: {{sprite.untrimmedSize.height}}
                {% if sprite.rotated %}Rotated: true {% endif %}
            }
            {% endfor %}

            導(dǎo)出的結(jié)果類似于:

             
            Sprite {
                Name: "car01"
                FrameX: 100
                FrameY: 129
                FrameWidth: 76
                FrameHeight: 47
                OffsetX: 0
                OffsetY: 0
                OriginalWidth: 76
                OriginalHeight: 47
                Rotated: true 
            }
             
            Sprite {
                Name: "car02"
                FrameX: 100
                FrameY: 51
                FrameWidth: 76
                FrameHeight: 47
                OffsetX: 0
                OffsetY: 0
                OriginalWidth: 76
                OriginalHeight: 47
                Rotated: true 
            }

            ...

            導(dǎo)出插件還支持js擴(kuò)展, 具體內(nèi)容請(qǐng)繼續(xù)參考官方文檔, 但對(duì)于簡單的文本格式, 這種方式已經(jīng)足夠了

            對(duì)比plist后, 發(fā)現(xiàn)plist中的垃圾信息極為多, 而且作為spriteframe的name居然帶有擴(kuò)展名...  因此脫離plist,編寫自己的導(dǎo)出插件才是王道!

            久久综合九色综合久99| 久久精品免费观看| 国产福利电影一区二区三区,免费久久久久久久精 | 精品久久久无码21p发布| 久久天天躁狠狠躁夜夜躁2014| 久久久无码精品亚洲日韩按摩 | 97热久久免费频精品99| 一本大道加勒比久久综合| 天天综合久久一二三区| 97久久超碰成人精品网站| 精品熟女少妇aⅴ免费久久| 久久棈精品久久久久久噜噜| 久久久久久国产a免费观看不卡| 亚洲色大成网站www久久九| 久久精品国产99国产精品| 人妻无码久久一区二区三区免费| 久久97久久97精品免视看| 国产V综合V亚洲欧美久久| 久久亚洲精品国产亚洲老地址| 久久综合狠狠综合久久激情 | 一本色道久久综合狠狠躁| 色综合久久中文字幕综合网| 久久精品无码专区免费青青| 97视频久久久| 欧美久久久久久| 色偷偷91久久综合噜噜噜噜| 2020最新久久久视精品爱| 欧美精品一本久久男人的天堂| 久久人人爽人人爽人人片av高请| 久久精品一本到99热免费| 中文字幕无码久久人妻| 久久免费视频一区| 国产综合免费精品久久久| 久久996热精品xxxx| 午夜视频久久久久一区| 国产精品久久久久蜜芽| 国产精品久久久久久久人人看| 人妻无码久久精品| 国内精品伊人久久久久av一坑| 亚洲国产欧美国产综合久久 | 一级女性全黄久久生活片免费|