I have a sprite sheet that I created using Texture Packer. The png file and plist file it generates are in my project.
One of the sprites from the sheet is used as a mask by CCControlSwitch. I have a problem with this particular sprite.
My code to load from the sprite sheet is as follows:
CCSpriteFrameCache *cacher = CCSpriteFrameCache::sharedSpriteFrameCache();
CCSprite *maskSprite = new CCSprite;
maskSprite->initWithFile("switch-mask.png"); // this works fine
maskSprite->initWithSpriteFrameName("switch-mask.png"); // this does not work
All sprites from the sheet load and work OK apart from my mask. If I include the individual png and load it via initWithFile it works fine. If I load it from the sheet via initWithSpriteFrameName, it behaves strangely. By strangely I mean that the mask seems to be stretched and this effects the positioning of the other items that make up my CCControlSwitch.
I should note that CCControlSwitch applies a shader to the mask texture (see ccShaderEx_SwitchMask_frag.h). It looks as though the shader is seeing the size of the entire sprite sheet (256x256) rather than the size of the mask itself?