Image shifts right after animation completes
I have an animation I'm running from a spritesheet. On the last frame of the animation, the image seems to move to the bottom-right of the sprite boundary. There's a video here:
http://vimeo.com/27347999
I can't find anything wrong with my code; the problem may be with the spritesheet property list, which I made with Zwoptex. Here's the property list:
https://gist.github.com/1128291
And the relevant source:
//initialize
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:[images objectForKey:@"elephantPlist"]];
elephantSpritesheet = [CCSpriteBatchNode batchNodeWithFile:[images objectForKey:@"elephantSpritesheet"]];
elephant = [TouchableSprite spriteWithSpriteFrameName:@"elephant_1.png"];
elephant.delegate = self;
[self addChild:elephantSpritesheet];
[elephantSpritesheet addChild:elephant];
.
- (void)animateElephant{
NSArray *frames = [self makeFrameNames:@"elephant" numFrames:15];
CCAnimation *animation = [CCAnimation animationWithFrames:frames delay:0.05f];
CCAnimate *animate = [CCAnimate actionWithAnimation:animation];
[elephant runAction:animate];
}
开发者_运维百科One more thing, changing the frame that the animation stops on does not fix the problem. That is, if I only use frames 1 through 10 instead of through 15, the 10th frame will jump downward and to the left, just like the 15th did.
I'm not sure why, but I turned off trimming in Zwoptex and that resolved the issue.
精彩评论