You are on page 1of 3

Getting started with TexturePacker and CoronaSDK image sheets

1/21/14 6:27 PM

Code'n'Web

TexturePacker

PhysicsEditor

Movie

Book

ShowRoom

Blog

Store

Search

Getting started with TexturePacker and CoronaSDK image sheets


Andreas Lw texturepacker, tutorial, corona This is a short tutorial how to use TexturePacker with the new ImageSheet API from Corona SDK. The API is not yet documented and might still be unstable... You need one of the current nightly builds of CoronaSDK which includes the new API. To use the new API with TexturePacker you need the current 3.0.0 build which is currently available as beta version from the download section of this page.

Overview over the important les


spritesheet.tps - TexturePacker file to create the sprite sheets spritesheet.lua - Sprite definition file ("old" format) spritesheet.png - Png image containing the sprite data main.lua - The code driving the example

The complete code


First load the image sheet information file created with TexturePacker into memory
local sheetInfo = require("spritesheet")

Load the created image file:


local myImageSheet = graphics.newImageSheet( "spritesheet.png", sheetInfo:getSheet() )

To place a file create a new image Object with newImage, using the image sheet loaded before. You can select individual sprites by their name using getFrameIndex:
local myImage1 = display.newImage( myImageSheet , sheetInfo:getFrameIndex("drink")) local myImage2 = display.newImage( myImageSheet , sheetInfo:getFrameIndex("hamburger"))

Source code available for download


The source code is available on GitHub. Either clone it using git:
git clone https://github.com/AndreasLoew/TexturePacker-Corona-ImageSheets.git

or download one of the archives: TexturePacker-Corona-ImageSheets.zip TexturePacker-Corona-ImageSheets.tar.gz

http://www.codeandweb.com/blog/2012/05/09/texturepacker-corona-imagesheet-tutorial

Page 1 of 3

Getting started with TexturePacker and CoronaSDK image sheets

1/21/14 6:27 PM

8 comments Join the discussion


Best Community Jerry Adkins 6 rjk
!

Share

Login

10 months ago

How about an animated example?


! Reply ! Share

2 years ago

I have just purchased this and tried to use with corona sdk. I am using dynamic content scaling and everything looks good on the iPhone but if I go up to the iPad nothing lines up. I think that it's using the iPad size image but still trying to use the iPhone size data file. Is there a way in texture packer to make sure the image I export at standard size, 2x and 4x are all the same just scaled up so that the data will line up perfectly with the standard size datafile.
2
! Reply ! Share

IntenseMediaDotCom

3 months ago

what does "21 not fitting sprites - try multipacking, Size: 2048x2048 (16384kB)" refer to? I can assure you I don't have any images that size. However I have over 48 image backgrounds that are 1024 x 768. What do I do with those larger files? Do I create a background only image folder?
! Reply ! Share

IntenseMediaDotCom

3 months ago

I use a lot of full size images in my apps: photos, background scenes that change from one page to another. Is there a way to use TexturePacker with these larger files? Is there any way I can optimize my graphics more efficiently using TexturePacker?
! Reply ! Share

eik

11 months ago

local myImage2 = display.newImage( myImageSheet , sheetInfo:getFrameIndex("hamburger")) On the 3rd parameter there, looks confusing so I just use my own sequencing information. I can't find any examples on the usefulness of 'sheetInfo:getFrameIndex("hamburger")?'
! Reply ! Share

sathya

a year ago

how to accomodate different device image problem in corona sdk


! Reply ! Share

AndreasLoew

Mod

sathya ! a year ago

Use "Force Identical Layout" in TexturePacker 3.0.0


! Reply ! Share

sathya

a year ago

how to solve the different size image problem for different size in corona sdk
! Reply ! Share

ALSO ON CODEANDWEB

WHAT'S THIS?

How to scale content for Retina Display iPhone and iPad

TexturePacker Extension for ShiVa 3D


Page 2 of 3

http://www.codeandweb.com/blog/2012/05/09/texturepacker-corona-imagesheet-tutorial

Getting started with TexturePacker and CoronaSDK image sheets

1/21/14 6:27 PM

How to scale content for Retina Display iPhone and iPad for cocos2d
6 comments a year ago

TexturePacker Extension for ShiVa 3D


1 comment a year ago

kilik she say that's for me

nish can u plz tell me the size of the video thumbnail in

iphone 5 ???

TexturePacker.onSetObjectTexture: hashtable entry not found.i missing somethinks

What is a sprite sheet? - The Movie - Performance


10 comments a year ago

UIKit Animations with TexturePacker


4 comments 8 months ago

OR PICK A NAME This video (and its predecessor) are simply

Daniel How can i play animation one-by-one?

wonderful! The explanation was straight-forward, and the funky graphics appealed to my visual learning side.

Subscribe

Add Disqus to your site

Join the Code'n'Web Newsletter (privacy policy)

your email address

Join

Copyright 2009-2014 Andreas Lw. All rights reserved.

Imprint

Request free license

Lost license

Support

Privacy Policy

http://www.codeandweb.com/blog/2012/05/09/texturepacker-corona-imagesheet-tutorial

Page 3 of 3