free-tex-packer-core icon indicating copy to clipboard operation
free-tex-packer-core copied to clipboard

Add Cocos3d exporter with plist format3

Open aztack opened this issue 2 years ago • 0 comments

Cocos Creator (AFIK 3.3.0 and 2.4.8) rotates the image by 90deg clockwise with Sharp when generating an atlas:

image While `Jimp.rotate(90)` is counter-clockwise.

Please consider rotating 90deg clockwise when exporting toCocos2d with plist format3.

Here is a proposal of Cocos2d.mst:

{{=<% %>=}}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>frames</key>
    <dict>
      <%#rects%>
      <key><%&name%></key>
      <dict>
        <key>aliases</key>
        <array/>
        <key>spriteOffset</key>
        <string>{<% spriteSourceSize.x | offsetLeft : spriteSourceSize.w : sourceSize.w %>,<% spriteSourceSize.y | offsetRight : spriteSourceSize.h : sourceSize.h %>}</string>
        <key>spriteSize</key>
        <string>{<%spriteSourceSize.w%>,<%spriteSourceSize.h%>}</string>
        <key>spriteSourceSize</key>
        <string>{<%sourceSize.w%>,<%sourceSize.h%>}</string>
        <key>textureRect</key>
        <string>{{<%frame.x%>,<%frame.y%>},{<%frame.w%>,<%frame.h%>}}</string>
        <key>textureRotated</key>
        <<%rotated%>/>
      </dict>
      <%/rects%>
    </dict>
    <key>metadata</key>
    <dict>
      <key>format</key>
      <integer>3</integer>
      <key>pixelFormat</key>
      <string><%config.format%></string>
      <key>premultiplyAlpha</key>
      <false/>
      <key>realTextureFileName</key>
      <string><%config.imageFile%></string>
      <key>size</key>
      <string>{<%config.imageWidth%>,<%config.imageHeight%>}</string>
      <key>textureFileName</key>
      <string><%config.imageName%></string>
    </dict>
  </dict>
</plist>
<%={{ }}=%>

summary

  • Change rotate(90) to rotate(-90) when export for Cocos
  • Maybe add an option rotationDirection into config rotation cw/ccw like CustomExporter
  • Update Cocos2d exporter from plist format2 to format

update: Here is a PR also fix the rotation issue:

aztack avatar Jul 13 '23 06:07 aztack