extracting sprite from within a texture packed image

Hi All,

I have two images and a sprite sheet (in the form of a png image) in my project. I used texture packer to pack the two images and one sprite sheet PNG into one file. Now I can easily get the two images using code like:

local star1 = display.newImage(gameAssets01Sheet, gameassets01_tp:getFrameIndex(“starsone”));

I am not able to extract and play the sprite sheet though.

Can I also extract the sprite sheet from the texture packed file and play my sprite?

regards,

P.S. The sprite sheet play fine if it is not packed into the texture packer.

Hi, 

Without seeing all your code it is hard to identify the problem.

Are you using newSprite and setting up the sequenceData so it knows what to animate??

Personally I use Level Director to import my TP files and use the built-in animator but if you want to do it manually then I suggest you take a look at the newSprite and newImageSheet documentation.

I am on MAC so Level Director won’t work for me.

Hi, 

Without seeing all your code it is hard to identify the problem.

Are you using newSprite and setting up the sequenceData so it knows what to animate??

Personally I use Level Director to import my TP files and use the built-in animator but if you want to do it manually then I suggest you take a look at the newSprite and newImageSheet documentation.

I am on MAC so Level Director won’t work for me.

This is how you would play the animation:

 myAnim = display.newSprite( parentGroup, gameAssets01Sheet, { time = 1000, loopCount = 0, frames = { gameassets01\_tp:getFrameIndex("ico1"), -- notice you must know the name of each frame gameassets01\_tp:getFrameIndex("ico2"), gameassets01\_tp:getFrameIndex("ico3"), } }) myAnim:setReferencePoint( display.CenterReferencePoint ) myAnim.x = 384 myAnim.y = 576 myAnim:play() --[[Sometimes, when I have a lot of frames with a sequenced number suffix, I use a loop local animFrames = {} for i=1,3 do animFrames[#animFrames+1] = gameassets01\_tp:getFrameIndex("ico"..i) end myAnim = display.newSprite( parentGroup, gameAssets01Sheet, { time = 1000, loopCount = 0, frames = animFrames }) ]]--

This is how you would play the animation:

 myAnim = display.newSprite( parentGroup, gameAssets01Sheet, { time = 1000, loopCount = 0, frames = { gameassets01\_tp:getFrameIndex("ico1"), -- notice you must know the name of each frame gameassets01\_tp:getFrameIndex("ico2"), gameassets01\_tp:getFrameIndex("ico3"), } }) myAnim:setReferencePoint( display.CenterReferencePoint ) myAnim.x = 384 myAnim.y = 576 myAnim:play() --[[Sometimes, when I have a lot of frames with a sequenced number suffix, I use a loop local animFrames = {} for i=1,3 do animFrames[#animFrames+1] = gameassets01\_tp:getFrameIndex("ico"..i) end myAnim = display.newSprite( parentGroup, gameAssets01Sheet, { time = 1000, loopCount = 0, frames = animFrames }) ]]--