现在的位置: 首页 > 综合 > 正文

TexturePacker与XCode4.6的集成

2014年08月24日 ⁄ 综合 ⁄ 共 3554字 ⁄ 字号 评论关闭

  今天花了几个钟头,终于把TexturePacker与XCode4.6的集成搞出来,期间遇到了很多错误,也参考了一些文章最后还是搞出来了,心中不免有一些欣喜吐舌头.

  我是在看着子龙山人的博客时遇到的这个问题,因为山人的博客还是2011年,xcode中的配置自是与现在的有些不同,同时我还在网上参考其他高人的博客,终于完成了tp与xcode的集成.参考的博客地址有:

 

http://blog.csdn.net/lql7781800/article/details/9211455

 

http://www.codeandweb.com/blog/2011/05/11/xcode4-integration-tutorial-of-texturepacker-for-cocos2d-and-sparrow-framework

  http://blog.csdn.net/zhaohuan_88/article/details/7878420

同时我从子龙山人的博客的评论中,我也发现广大的网友在这方面也有这方面的问题,我还是山人的回答中得到了一些非常好的回答,因为这些回答正是我为tp与xcode的集成提供了钥匙,在此表示非常的感谢.

  好了,废话不多说,让我们从实例开始,因为问题是从子山龙人打地鼠游戏中引发的,所以还是以那个实例说吧,项目的名称是TexturePacker,根据上面的博客我建的项目图如下:

子龙山人介绍的博客里PackTextures.sh是这样的

#!/bin/sh
TP="/usr/local/bin/TexturePacker"
if [ "${ACTION}"="clean" ]
then
echo "cleaning..."
rm resources/background*
rm resources/foreground*
rm resources/sprites*
else
echo "building..."
${TP} --smart-update \
--format cocos2d \
--data resources/background-hd.plist \
--sheet resources/background-hd.pvr.ccz \
--dither-fs \
--opt RGB565 \
Art/background/*.jpg
${TP} --smart-update \
--format cocos2d \
--data resources/background.plist \
--sheet resources/background.pvr.ccz \
--dither-fs \
--scale 0.5 \
--opt RGB565 \
Art/background/*.jpg
${TP} --smart-update \
--format cocos2d \
--data resources/foreground-hd.plist \
--sheet resources/foreground-hd.pvr.ccz \
--dither-fs-alpha \
--opt RGBA4444 \
Art/foreground/*.jpg
${TP} --smart-update \
--format cocos2d \
--data resources/foreground.plist \
--sheet resources/foreground.pvr.ccz \
--dither-fs-alpha \
--scale 0.5 \
--opt RGBA4444 \
Art/foreground/*.jpg
${TP} --smart-update \
--format cocos2d \
--data resources/sprites-hd.plist \
--sheet resources/sprites-hd.pvr.ccz \
--dither-fs-alpha \
--opt RGBA4444 \
Art/sprites/*.jpg
${TP} --smart-update \
--format cocos2d \
--data resources/sprites.plist \
--sheet resources/sprites.pvr.ccz \
--dither-fs-alpha \
--scale 0.5 \
--opt RGBA4444 \
Art/sprites/*.jpg
fi
exit 0

但是我们如果这样做的话,会发生很多的错误,诸如:

rm: resources/background*: No such file or directory
rm: resources/foreground*: No such file or directory
rm: resources/sprites*: No such file or directory
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

TexturePacker:: error: --auto-sd no longer supported, please use --variant.
TexturePacker:: error: --auto-sd no longer supported, please use --variant.
TexturePacker:: error: --auto-sd no longer supported, please use --variant.
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

什么.jpg文件找不到呀,不支持--auto-sd 等等

根据评论,我把

if [ "${ACTION}"="clean" ]
then
echo "cleaning..."
rm resources/background*
rm resources/foreground*
rm resources/sprites*
else

去掉了,jpg文件找不到,因为图片是png格式,sh文件的jpg换成png就行了,最后修改的最终模样

#!/bin/sh
TP="/usr/local/bin/TexturePacker"

echo "building..."
${TP} --smart-update \
--format cocos2d \
--data Resources/background-hd.plist \
--sheet Resources/background-hd.pvr.ccz \
--dither-fs \
--opt RGB565 \
Art/background/*.png
${TP} --smart-update \
--format cocos2d \
--data resources/background.plist \
--sheet resources/background.pvr.ccz \
--dither-fs \
--scale 0.5 \
--opt RGB565 \
Art/background/*.png
${TP} --smart-update \
--format cocos2d \
--data Resources/foreground-hd.plist \
--sheet Resources/foreground-hd.pvr.ccz \
--dither-fs-alpha \
--opt RGBA4444 \
Art/foreground/*.png
${TP} --smart-update \
--format cocos2d \
--data resources/foreground.plist \
--sheet resources/foreground.pvr.ccz \
--dither-fs-alpha \
--scale 0.5 \
--opt RGBA4444 \
Art/foreground/*.png
${TP} --smart-update \
--format cocos2d \
--data Resources/sprites-hd.plist \
--sheet Resources/sprites-hd.pvr.ccz \
--dither-fs-alpha \
--opt RGBA4444 \
Art/sprites/*.png
${TP} --smart-update \
--format cocos2d \
--data resources/sprites.plist \
--sheet resources/sprites.pvr.ccz \
--dither-fs-alpha \
--scale 0.5 \
--opt RGBA4444 \
Art/sprites/*.png

exit 0

还有一些的路径问题,设成如图所示就可以了

编译运行TexturePacker成功,在Resource中生成了我们要的文件

【上篇】
【下篇】

抱歉!评论已关闭.