I used TexturePacker to create a spritesheet and a PLIST to contain them. The problem is that, it doesn’t show the whole sprite but only a part of it.
If you look at the trees, there are colored parts, the most obvious one is the one with G. It’s supposed to be a 96x96 circle.
Here’s how I draw them:
void Fruit::draw() {
char l_file[24];
sprintf( l_file, "fruit_%d_%d.png", getType(), getState() );
CCSpriteFrameCache::sharedSpriteFrameCache() -> addSpriteFramesWithFile("fruits.plist");
CCSpriteFrame * l_SpriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache() -> spriteFrameByName( l_file );
if ( l_SpriteFrame != NULL ) {
std::cout << "[ TEST ] " << l_SpriteFrame -> getTexture() -> getName() << std::endl;
this -> m_Sprite = CCSprite::create( l_SpriteFrame );
} else {
GGFGraphics::GGFLOG( "Cannot find sprite in spritesheet. Will use raw image instead.", 'w' );
this -> m_Sprite = CCSprite::create( l_file );
}
this -> m_Sprite -> setScale( GGFGraphics::scalingFactor );
this -> m_Sprite -> setPosition( GGFGraphics::treePos.at( Profile::garden ).at( m_Slot ) );
this -> setDefaultPosition( m_Sprite -> getPosition( ).x, m_Sprite -> getPosition( ).y );
}
I have set a batch node in the main layer, too. Any help?