Cocos2d-x How to get CCSpriteFrame from cache

/* Get  CCSpriteFrame from file */
CCSpriteFrame* Global::getFrameFromImage(const char* imagefile, int x, int y, int w ,int h) {
    CCSpriteFrame *frame ;
    CCSpriteBatchNode *spriteSheet;
    bool check = Global::checkFileExistInResource(imagefile);
   
    if(check) {
        spriteSheet = CCSpriteBatchNode::create(imagefile);
    } else {
        spriteSheet = CCSpriteBatchNode::createWithTexture(Global::getTextureFromImage(imagefile));
    }
    spriteSheet = CCSpriteBatchNode::createWithTexture(Global::getTextureFromImage(imagefile));
   
    frame = CCSpriteFrame::createWithTexture(spriteSheet->getTexture() ,CCRectMake(0,0,w,h));
   
    return frame;

   
}


CCSpriteFrame* Global::getFrameFromCache(const char* plistfile ,const char* frameName) {
    CCSpriteFrameCache ::sharedSpriteFrameCache() -> addSpriteFramesWithFile(plistfile);
    return CCSpriteFrameCache ::sharedSpriteFrameCache()-> spriteFrameByName(frameName);
}

CCSpriteFrame* Global::getSpriteFromCache(const char* frameName) {
    return CCSpriteFrameCache ::sharedSpriteFrameCache()-> spriteFrameByName(frameName);
}

Comments

Popular posts from this blog

Java : Variables Declaring

Install DNF in RHEL/CentOS 7

SQL Self JOIN