boolCCSprite::initWithFile(const char *pszFilename, const CCRect&rect)
{
CCAssert(pszFilename != NULL, "");
CCTexture2D *pTexture =CCTextureCache::sharedTextureCache()->addImage(pszFilename);
if (pTexture)
{returninitWithTexture(pTexture,rect);
}
return false;
}
boolCCSprite::initWithSpriteFrameName(const char *pszSpriteFrameName)
{
CCAssert(pszSpriteFrameName != NULL, "");
CCSpriteFrame *pFrame =
CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName);
return initWithSpriteFrame(pFrame);
}
CCSprite* pSprite = CCSprite::spriteWithFile("grossini.png");
CC_BREAK_IF(! pSprite);
CCSize size = CCDirector::sharedDirector()->getWinSize();
// Place the sprite on the center of the screen
pSprite->setPosition(ccp(size.width/2, size.height/2));
// Add the sprite to HelloWorld layer as a child layer.
this->addChild(pSprite, 0);