Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.

TexturePacker XCode Integration - 5 minutes that save hours

This small guide shows you how to fully integrate TexturePacker into XCode. This is what really saves time: You use 5 minutes to set things up and never care about sprite sheets anymore!

Advantages:

  • 5 minute setup
  • Saves hours of clicking
  • Automated updates of the sprite sheet
  • Full integraction including clean and build phase
  • Building sheets only when things changed
  • Automated creation of hd and sd sheets on the fly from hd assets only
  • Complete control directly from XCode

Preparing

Asumptions
  • Your sprites are hd and located in your project directory assets. All sprites for one sheet are in one directory - sheet1 in this example. If you use sd only thats no problem - you just have to leave out the hd parts and remove the –scale 0.5 from the script.
  • Your output sheet will be in resources.

This script is for TexturePacker 1.1.0. Please upgrade to this version if you still have an older one.

Script setup
#! /bin/sh

TP="/usr/local/bin/TexturePacker"

if [ "${ACTION}" = "clean" ]
then
    echo "cleaning..."
    rm ${SRCROOT}/resources/sheet1.png
    rm ${SRCROOT}/resources/sheet1.plist
    
    rm ${SRCROOT}/resources/sheet1-hd.png
    rm ${SRCROOT}/resources/sheet1-hd.plist
    
    # ....
    # add all files to be removed in clean phase
    # ....
else
    echo "building..."
    
    # create hd assets
    ${TP} --smart-update \
          --format cocos2d \
          --data ${SRCROOT}/resources/sheet1-hd.plist \
          --sheet ${SRCROOT}/resources/sheet1-hd.png \
          ${SRCROOT}/assets/sheet1/*.png
  
    # create sd assets from hd sprites
    ${TP} --smart-update --scale 0.5 --max-size 1024 \
          --format cocos2d \
          --data ${SRCROOT}/resources/sheet1.plist \
          --sheet ${SRCROOT}/resources/sheet1.png \
          ${SRCROOT}/assets/sheet1/*.png

    # ....
    # add other sheets to create here
    # ....
fi
exit 0

The importan thing is that you don't forget –smart-update because this enables a check for not creating the sheets if nothing is to be done.

If you use sd only remove the hd part and use

    # create sd assets from sd sprites
    ${TP} --smart-update --max-size 1024 \
          --format cocos2d \
          --data ${SRCROOT}/resources/sheet1.plist \
          --sheet ${SRCROOT}/resources/sheet1.png \
          ${SRCROOT}/assets/sheet1/*.png

instead.

You can add the script to your XCode source tree to be able to change the settings without using an external editor.

Integration

Add a new external target to your build

Add new target to your project:

Use external target:

Give it a name:

Edit the new target

Now you should be able to run the target with build and clean.

Add the new target to your project's dependencies

Double click your main target and add the dependency to the TexturePacker target:

The result

This is how the project look in the end:

Screenshots ;-)

Build

Rebuild

Clean

Have fun ;-) Andreas

tips/texturepacker-xcode-integratiion.txt · Last modified: 2010/10/01 03:19 by aloew
Trace: migrate_to_v2.0 0_8_rc 0_8_rc2 1_1_0 lesson_1._install_test director_transparentview instructions multiline_label slider_widget texturepacker-xcode-integratiion
Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0