Strange sprite animation problem on iOS Devices

Hi all,

I encountered strange problem on iOS devices.

I made up a single spritesheet file for sprite animation. There are sprite frame images in this spritesheet like this sequence.
ani_house_bread_lv1_xx.png

When I run the animation from this spritesheet, the building seems shaking left<>right, which is completely fine on iOS simulator and Android devices.
The codes I tested for this sprite animation is like following 2.
Code 1
<pre>
void createAnimationFromPlistToSprite
{
CCAnimationCache* animCache = CCAnimationCache::sharedAnimationCache;
CCAnimation* animation = animCache
>animationByName( animation_name );
if( animation==NULL )
{
CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
frameCache~~>addSpriteFramesWithFile;
animation = CCAnimation::create;
CCFileUtils* fileUtils = CCFileUtils::sharedFileUtils;
const char* fullPath = fileUtils~~>fullPathForFilename( animation_plist_path ).c_str();
CCDictionary* dictionary = CCDictionary::createWithContentsOfFileThreadSafe( fullPath );
CCDictionary* framesDict = static_cast<CCDictionary*>( dictionary~~>objectForKey );
CCArray* keys = framesDict~~>allKeys();
for( int i = 0 ; i < keys~~>count; ++i )
{
CCString* spriteFileName = static_cast<CCString*> );
CCSpriteFrame* sprite = CCSpriteFrameCache::sharedSpriteFrameCache~~>spriteFrameByName );
animation~~>addSpriteFrame;
}
animation~~>setDelayPerUnit( delayPerUnit );
animation~~>setRestoreOriginalFrame;
animCache~~>addAnimation( animation, animation_name );
}
else
{
CCLog( “## Animation(%s) is already in Cache”, animation_name );
}
if( animation )
{
if( pSprite!=NULL )
{
CCArray* aniframes = animation~~>getFrames;
if>0 )
{
CCAnimationFrame* aniframe = static_cast<CCAnimationFrame*> );
pSprite~~>initWithSpriteFrame( aniframe~~>getSpriteFrame );
}
}
}
}

void startAnimationInSprite
{
CCAnimationCache* animCache = CCAnimationCache::sharedAnimationCache;
CCAnimation* animation = animCache~~>animationByName( animation_name );
if( animation )
{
CCAction* action = NULL;
if(loop)
{
animation~~>setLoops;
//action = CCRepeatForever::create);
action = CCAnimate::create;
}
else
{
animation~~>setLoops(1);
action = CCAnimate::create( animation );
}

// CCMoveBy* moveby = CCMoveBy::create(0, ccp(0,120));
// pSprite~~>runAction;
// CCSequence* seq = CCSequence::create;
pSprite~~>runAction( action );
}
}

void startAnimationInSprite(const char* plistfile,
const char* animation_name,
CCSprite* pSprite,
bool loop)
{
CCAnimationCache* animCache = CCAnimationCache::sharedAnimationCache();
CCAnimation* animation = animCache->animationByName( animation_name );
if( !animation )
{
createAnimationFromPlistToSprite( plistfile, animation_name );
}
startAnimationInSprite(animation_name, pSprite, loop);
}

Code 2

And I tried AdvanceSprite class from
http://www.cocos2d-x.org/forums/6/topics/1792
[[http://www.cocos2d-x.org/forums/6/topics/1792]]

Have anyone encountered this before?
cocos2d-x library I am using is “cocos2d-x-2.2.0”

Thanks in advance.


house_bread.plist.zip (1.1 KB)


house_bread.png (2384.6 KB)

Did you use TexturePacker? Try to set Trim mode to none.

Thanks, I tried that but no difference. :frowning:

I finally found out the working combination of TexturePacker setting.

Pls refer to the screenshot image attached.

The’Scale’ option is for the case when some of the original images can not fit into the final sprite sheet image. The options like POT prevent the most compact packing of the images so the final image sheet will be bigger and less of the original images will be contained. If you need to pack all the images into a single sprite sheet image, scale them with the scale less than 1.

where is the screenshot?