改变cocos 2d x中动画精灵的比例

时间:2014-05-30 05:36:23

标签: animation cocos2d-x ccsprite cocos2d-x-3.0

如果我的图像非常大,我怎样才能使动画精灵更小。我试过bird->setScale(0.5f);,但我并没有减少比例。 以下是我为sprite设置动画的代码。

int numframe = 3;
CCArray* frames = CCArray::createWithCapacity(numframe);

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("bird-anim.plist");
CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();


char file[100] = {0};
for (int i = 0; i < numframe; i++)
{
    sprintf(file, "bird-anim%d.png", i+1);
    CCSpriteFrame* frame = frameCache->spriteFrameByName(file);
    frames->addObject(frame);
}

CCAnimation* animation = CCAnimation::createWithSpriteFrames(frames, 0.1);
CCAnimate* animate = CCAnimate::create(animation);
CCRepeatForever* repeat = CCRepeatForever::create(animate);

bird->runAction(repeat);
bird->setScale(0.7); 

0 个答案:

没有答案