0
votes

I am loading a sprite sheet with the code below:

[cache addSpriteFramesWithFile:[NSString stringWithUTF8String:plistPath] textureFilename:[NSString stringWithUTF8String:spritePath]];

Then I set my current frame of my animations using:

[this->fSprite setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithUTF8String:fAnimFSM->GetCurrentImageSequence()->fImages[frame]]]];

The correct frame comes up but it appears that the bottom frame of the frame directly above my current frame is also being rendered. As you can see in the below image you can see what looks like a 1 pixel horizontal line above my my current frame of animation.

1 pixel line above my current frame

The plist looks perfect to me, plus I have 5+ animations in my sprite sheet and only 1 animation suffers from this problem.

What could this be?

Thanks in advance.

1
How do you create the sprite frames/texture atlas? Most tools default to a distance of 2 pixels between any two images to prevent this exact problem.LearnCocos2D
@LearnCocos2D I am awaiting on my graphics team to update this for me. As soon as I know I'll come back and let you know. They are currently on vacation.Michael Wildermuth
@LearnCocos2D Please add your comment as the solution, so I can accept it. Thanks.Michael Wildermuth

1 Answers

1
votes

Leave a 2-pixel wide space in your texture atlas around every image. Tools like TexturePacker can be configured (and default to) using the 2-pixel wide margin. Without the 2-pixel gap glitches like the above are inevitable.