cocos2d-x的plist文件

////---------------通過資源文件創建動畫
    CCTexture2D::PVRImagesHavePremultipliedAlpha(true);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("crop.plist");//單例模式。
    
    //利用幀緩存創建精靈
    CCSprite* sp = CCSprite::createWithSpriteFrameName("crop1.png");
    sp->setPosition(ccp(170,200));
    addChild(sp);
    
    CCArray* animFrames = CCArray::createWithCapacity(4);
    char str[100] = {0};
    for(int i = 1; i < 5; i++)
    {
        sprintf(str, "crop%i.png", i);
        CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str);
        animFrames->addObject(frame);
    }
    CCAnimation *animation = CCAnimation::createWithSpriteFrames(animFrames, 0.3f);
    animation->setLoops(-1);
    
    sp->runAction(CCAnimate::create(animation));
    CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFrameByName("crop.plist")


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章