• <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>

            戰魂小筑

            討論群:309800774 知乎關注:http://zhihu.com/people/sunicdavy 開源項目:https://github.com/davyxu

               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              257 隨筆 :: 0 文章 :: 506 評論 :: 0 Trackbacks

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

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

            本人參考shiva3d插件, 對應導出界面的DataFormat中的Shiva3D, 快速學會了如何導出

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

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

            bin\exporters\下的某一目錄下存在的一個名為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字段中, 描述同目錄的導出文件格式模板. TexturePacker使用一種叫Grantlee的模板引擎,類似于Python使用的Django模板引擎, 文檔參見:Grantlee Documentation. 簡單的文本格式可以參考shiva.xml快速學會

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

             

            {% 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 %}

            導出的結果類似于:

             
            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 
            }

            ...

            導出插件還支持js擴展, 具體內容請繼續參考官方文檔, 但對于簡單的文本格式, 這種方式已經足夠了

            對比plist后, 發現plist中的垃圾信息極為多, 而且作為spriteframe的name居然帶有擴展名...  因此脫離plist,編寫自己的導出插件才是王道!

            posted on 2014-02-06 15:23 戰魂小筑 閱讀(5269) 評論(0)  編輯 收藏 引用 所屬分類: 游戲開發技術C++/ 編程語言工具使用及設計
            国产精品天天影视久久综合网| 久久久久亚洲AV无码专区桃色| 久久综合狠狠综合久久综合88| 99久久精品日本一区二区免费| 久久93精品国产91久久综合| 久久精品青青草原伊人| 女人香蕉久久**毛片精品| 亚洲国产视频久久| 国产高潮久久免费观看| 久久久久久久久无码精品亚洲日韩 | …久久精品99久久香蕉国产| 久久九九久精品国产免费直播| 亚洲色欲久久久综合网东京热| 久久成人18免费网站| 久久久久亚洲精品天堂| 亚洲国产日韩欧美综合久久| 久久综合综合久久97色| 精品久久久久久成人AV| 一级女性全黄久久生活片免费 | 久久人人爽人人澡人人高潮AV| 青草国产精品久久久久久| 亚洲午夜久久久| 久久免费99精品国产自在现线| 精品久久久久久综合日本| 伊人久久大香线焦AV综合影院| 亚洲国产天堂久久久久久 | 亚洲综合伊人久久大杳蕉| 亚洲欧美国产精品专区久久| 久久e热在这里只有国产中文精品99| 久久精品国产亚洲一区二区| 亚洲色大成网站WWW久久九九| 狠狠色丁香久久婷婷综合_中 | 国产精品美女久久久m| 狼狼综合久久久久综合网| 日韩精品无码久久久久久| 亚洲午夜久久久久久噜噜噜| 亚洲国产精品成人久久| 久久精品国产亚洲精品2020| 99久久婷婷国产综合亚洲| 欧美综合天天夜夜久久| 精品久久久久久国产免费了|