I am searchig in the internet, in this forum, in the source code of the cocs2d, but I can not get it.
I am trying to make a button out of a sprite. The sprite is created from a file, but is additionally colored and has a child:
CCSprite *buttonOffSprite = [CCSprite spriteWithImageNamed:@"button_body.png"];
buttonOffSprite.color = [CCColor redColor];
CCSprite *elementSprite = [CCSprite spriteWithImageNamed:@"element.png"];
elementSprite.color = [CCColor blackColor];
In the init method of CCButton I need to use "CCSpriteFrame":
[initWithTitle:@"" spriteFrame: highlightedSpriteFrame: disabledSpriteFrame:]
CCSpriteFrame *buttonOffSpriteFrame = buttonOffSprite.spriteFrame;
delivers only spriteFrame, which is equal to button_body.png (=initial frame). The color and the child are not part of it.
I've tried also creation of SpriteFrame out of sprite's texture:
buttonOffSpriteFrame = [CCSpriteFrame frameWithTexture:buttonOffSprite.texture rectInPixels:buttonOffSprite.textureRect rotated:buttonOffSprite.textureRectRotated offset: ccp(0,0) originalSize:buttonOffSprite.contentSize];
, but it gives me the same (just part of button_body.png, probably the offset is not correct ).
Imagine a sprite, which is created dynamically by adding children, rotating, coloring. How can I get CCSpriteFrame out of such sprite, which contains all elements and could be used for a creation of a CCButton?